Skip to content

Commit bb1091a

Browse files
Update Usage.md
1 parent 6095454 commit bb1091a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Documentation/Usage.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,19 +275,24 @@ Ethereum addresses are checksum checked if they are not lowercased or uppercased
275275
#### Getting ETH balance
276276

277277
```swift
278-
let address = EthereumAddress("0xE6877A4d8806e9A9F12eB2e8561EA6c1db19978d")!
278+
let address = EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")!
279279
let web3Main = Web3.InfuraMainnetWeb3()
280280
let balanceResult = web3Main.eth.getBalance(address)
281281
guard case .success(let balance) = balanceResult else {return}
282282
```
283283

284284
#### Getting ERC20 token balance
285285
```swift
286-
let contractAddress = EthereumAddress("0x45245bc59219eeaaf6cd3f382e078a461ff9de7b")! // BKX token on Ethereum mainnet
286+
let contractAddress = EthereumAddress("0x8932404A197D84Ec3Ea55971AADE11cdA1dddff1")! // w3s token on Ethereum mainnet
287287
let contract = web3.contract(Web3.Utils.erc20ABI, at: contractAddress, abiVersion: 2)! // utilize precompiled ERC20 ABI for your concenience
288-
guard let bkxBalanceResult = contract.method("balanceOf", parameters: [coldWalletAddress] as [AnyObject], options: options)?.call(options: nil) else {return} // encode parameters for transaction
289-
guard case .success(let bkxBalance) = bkxBalanceResult, let bal = bkxBalance["0"] as? BigUInt else {return} // bkxBalance is [String: Any], and parameters are enumerated as "0", "1", etc in order of being returned. If returned parameter has a name in ABI, it is also duplicated
290-
print("BKX token balance = " + String(bal))
288+
guard let w3sBalanceResult = contract.method(
289+
"balanceOf",
290+
parameters: [coldWalletAddress] as [AnyObject],
291+
options: options
292+
)?.call(options: nil)
293+
else {return} // encode parameters for transaction
294+
guard case .success(let w3sBalance) = w3sBalanceResult, let bal = w3sBalance["0"] as? BigUInt else {return} // w3sBalance is [String: Any], and parameters are enumerated as "0", "1", etc in order of being returned. If returned parameter has a name in ABI, it is also duplicated
295+
print("w3s token balance = " + String(bal))
291296
```
292297

293298
## Transactions Operations

0 commit comments

Comments
 (0)