Skip to content

Commit c82757b

Browse files
Update README.md
1 parent 35239a0 commit c82757b

File tree

1 file changed

+26
-42
lines changed

1 file changed

+26
-42
lines changed

README.md

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
- [x] Interactions (read/write to Smart contracts) :arrows_counterclockwise:
5656
- [x] Parsing TxPool content into native values (ethereum addresses and transactions) - easy to get pending transactions
5757
- [x] Event loops functionality
58+
- [x] Supports Web3View functionality - WKWebView with injected "web3" provider
59+
- [x] Possibility to add or remove "middleware" that intercepts, modifies and even cancel transaction workflow on stages "before assembly", "after assembly"and "before submission"
5860
- [x] Literally following the standards:
5961
- [x] [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) HD Wallets: Deterministic Wallet
6062
- [x] [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) (Seed phrases)
@@ -173,51 +175,32 @@ For example: you want to interact with smart-contract and all you know is - its
173175

174176
You can get the ABI of your contract directly from [Remix IDE](https://remix.ethereum.org/) ([Solution](https://ethereum.stackexchange.com/questions/27536/where-to-find-contract-abi-in-new-version-of-online-remix-solidity-compiler?rq=1))
175177

176-
Then you should use contract address and ABI in creating contract object:
178+
Then you should use contract address and ABI in creating contract object. In example we use Infura Mainnet:
177179
```swift
178-
let contract = Web3.InfuraMainnetWeb3().contract(<abiString: String>, at: <EthereumAddress?>, abiVersion: <Int>)
180+
let yourContractABI: String = <CONTRACT JSON ABI>
181+
let toEthereumAddress: EthereumAddress? = <DESTINATION ETHEREUM ADDRESS>
182+
let abiVersion: Int = <ABI VERSION NUMBER>
183+
184+
let contract = Web3.InfuraMainnetWeb3().contract(yourContractABI, at: toEthereumAddress, abiVersion: abiVersion)
179185
```
180-
To create transaction you should call some contract method:
186+
Here is the example how you should call some contract method:
181187
```swift
182-
let transaction = contract.method(<method: String>, parameters: <[AnyObject]>, extraData: <Data>, options: <Web3Options?>)
188+
let method: String = <CONTRACT METHOD NAME>
189+
let parameters: [AnyObject] = <PARAMETERS>
190+
let extraData: Data = <DATA>
191+
let transactionOptions: TransactionOptions = <OPTIONS>
192+
193+
let transaction = contract.read(method, parameters: parameters, extraData: extraData, transactionOptions: transactionOptions)
183194
```
184195

185-
Here is the function example that creates TransactionIntermediate object, that you can send to smart-contract:
196+
Here is the example how you should send transaction to some contract method:
186197
```swift
187-
let yourContractABI = """
188-
<CONTRACT JSON ABI>
189-
"""
190-
191-
func prepareTransaction(parameters: Data, gasLimit: BigUInt = 27500, completion: @escaping (Result<TransactionIntermediate>) -> Void) {
192-
DispatchQueue.global().async {
193-
guard let addressFrom: String = <YOURS WALLET ADDRESS> else {return}
194-
guard let ethAddressFrom = EthereumAddress(addressFrom) else {return}
195-
196-
let yourContractAddress = "<CONTRACT ETH ADDRESS>"
197-
guard let ethContractAddress = EthereumAddress(contractAddress) else {return}
198-
199-
let web3 = Web3.InfuraMainnetWeb3() //or any test network
200-
web3.addKeystoreManager(KeystoreManager.defaultManager)
198+
let method: String = <CONTRACT METHOD NAME>
199+
let parameters: [AnyObject] = <PARAMETERS>
200+
let extraData: Data = <DATA>
201+
let transactionOptions: TransactionOptions = <OPTIONS>
201202

202-
var options = Web3Options.defaultOptions()
203-
options.from = ethAddressFrom
204-
options.value = 0 // or any other value you want to send
205-
206-
guard let contract = web3.contract(yourContractJsonABI, at: ethContractAddress, abiVersion: 2) else {return}
207-
208-
guard let gasPrice = web3.eth.getGasPrice().value else {return}
209-
options.gasPrice = gasPrice
210-
options.gasLimit = gasLimit
211-
212-
guard let transaction = contract.method("<METHOD OF CONTRACT YOU WANT TO CALL>", parameters: [parameters] as [AnyObject], options: options) else {return}
213-
guard case .success(let estimate) = transaction.estimateGas(options: options) else {return} //here is estimated gas - something like confirming that you made a transaction correctly
214-
print("estimated cost: \(estimate)")
215-
216-
DispatchQueue.main.async {
217-
completion(Result.Success(transaction))
218-
}
219-
}
220-
}
203+
let transaction = contract.write(method, parameters: parameters, extraData: extraData, transactionOptions: transactionOptions)
221204
```
222205

223206
#### How to set test local node?
@@ -233,11 +216,12 @@ func setLocalNode(port: Int = 8545) -> Web3? {
233216

234217
- [x] [EIP-165](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md) (Creates a standard method to publish and detect what interfaces a smart contract implements - ERC-165)
235218
- [x] [EIP-777](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-777.md) (A new advanced token standard - ERC-777)
219+
- [x] [EIP-888](https://github.com/ethereum/EIPs/issues/888) (MultiDimensional Token Standard - ERC-888)
220+
- [x] [EIP-1400](https://github.com/ethereum/EIPs/issues/1411) (Security Token Standard - ERC-1400)
221+
- [x] [R-Token](https://github.com/harborhq/r-token) (Smart Contracts for applying regulatory compliance to tokenized securities issuance and trading)
222+
- [x] [SRC-20](https://swarm.fund/swarm-basics/) (Swarm protocol that enables the tokenization of assets on the blockchain - Security Tokens)
223+
- [x] [ST-20](https://github.com/PolymathNetwork/polymath-core) (ST-20 token is an Ethereum-based token implemented on top of the ERC-20 protocol that adds the ability for tokens to control transfers based on specific rules)
236224
- [x] [Objective-C] - a proxy bridge to build your DApp on Objective-C using web3swift
237-
- [x] Support Web3View functionality - WKWebView with injected "web3" provider
238-
- [x] Add or remove "middleware" that intercepts, modifies and even cancel transaction workflow on stages "before assembly", "after assembly"and "before submission"
239-
- [x] Put the groundwork for implementing hooks functionality
240-
- [x] No more "Web3Options" - new classes "ReadTransaction" and "WriteTransaction" with a variable "transactionOptions" used to specify gas price, limit, nonce policy, value
241225
- [x] [Complete Documentation](https://web3swift.github.io/web3swift)
242226

243227

0 commit comments

Comments
 (0)