Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
skywinder committed Sep 23, 2020
1 parent ca2060e commit f2756ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 1 addition & 5 deletions Documentation/web3swift 2.0 Migration Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ This guide is provided in order to ease the transition of existing applications

---

## Follow naming convention

Now you have to do "import Web3swift" (capitalization!) instead of "import web3swift" to follow naming convention.

## New pods

Now EthereumAddress and Ethereum ABI are separate projects. Use "//import EthereumAddress" and "import Ethereum ABI" everywhere you use them.
Expand Down Expand Up @@ -256,7 +252,7 @@ let balanceString = Web3.Utils.formatToEthereumUnits(balance, toUnits: .eth, dec

// web3swift 2.0
let address = EthereumAddress("<Address>")!
let web3Main = Web3.InfuraMainnetWeb3()
let web3 = Web3.InfuraMainnetWeb3()
let balance = try web3.eth.getBalance(address: address)
let balanceString = Web3.Utils.formatToEthereumUnits(balance, toUnits: .eth, decimals: 3)
```
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ let tx = contract.write(
##### Send ERC-20 Token

```swift
let web3 = Web3.InfuraMainnetWeb3()
let value: String = "1.0" // In Tokens
let walletAddress = EthereumAddress(wallet.address)! // Your wallet address
let toAddress = EthereumAddress(toAddressString)!
Expand All @@ -169,9 +170,19 @@ let tx = contract.write(
transactionOptions: options)!
```


##### Get account balance
```swift
let web3 = Web3.InfuraMainnetWeb3()
let address = EthereumAddress("<Address>")!
let balance = try web3.eth.getBalance(address: address)
let balanceString = Web3.Utils.formatToEthereumUnits(balance, toUnits: .eth, decimals: 3)
```

##### Write Transaction and call smart contract method

```swift
let web3 = Web3.InfuraMainnetWeb3()
let value: String = "0.0" // Any amount of Ether you need to send
let walletAddress = EthereumAddress(wallet.address)! // Your wallet address
let contractMethod = "SOMECONTRACTMETHOD" // Contract method you want to write
Expand Down

0 comments on commit f2756ac

Please sign in to comment.