You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run `carthage update` to build the framework. By default, Carthage performs checkouts and creates a new directory 'Carthage' in the same location as your Cartfile. Open this directory, go to 'Build' directory, choose iOS or macOS directory, and use the selected directory framework in your Xcode project.
118
123
124
+
- Swift Package
125
+
Open xcode setting and add this repo as a source
126
+
119
127
### Example usage
120
128
121
-
**Web3View example:**
129
+
130
+
##### Send Ether
131
+
132
+
```swift
133
+
let value: String="1.0"// In Ether
134
+
let walletAddress =EthereumAddress(wallet.address)!// Your wallet address
135
+
let toAddress =EthereumAddress(toAddressString)!
136
+
let contract = web3.contract(Web3.Utils.coldWalletABI, at: toAddress, abiVersion: 2)!
137
+
let amount = Web3.Utils.parseToBigUInt(value, units: .eth)
138
+
var options = TransactionOptions.defaultOptions
139
+
options.value= amount
140
+
options.from= walletAddress
141
+
options.gasPrice= .automatic
142
+
options.gasLimit= .automatic
143
+
let tx = contract.write(
144
+
"fallback",
145
+
parameters: [AnyObject](),
146
+
extraData: Data(),
147
+
transactionOptions: options)!
148
+
```
149
+
150
+
##### Send ERC-20 Token
151
+
152
+
```swift
153
+
let value: String="1.0"// In Tokens
154
+
let walletAddress =EthereumAddress(wallet.address)!// Your wallet address
155
+
let toAddress =EthereumAddress(toAddressString)!
156
+
let erc20ContractAddress =EthereumAddress(token.address)!
157
+
let contract = web3.contract(Web3.Utils.erc20ABI, at: erc20ContractAddress, abiVersion: 2)!
158
+
let amount = Web3.Utils.parseToBigUInt(value, units: .eth)
159
+
var options = TransactionOptions.defaultOptions
160
+
options.value= amount
161
+
options.from= walletAddress
162
+
options.gasPrice= .automatic
163
+
options.gasLimit= .automatic
164
+
let method ="transfer"
165
+
let tx = contract.write(
166
+
method,
167
+
parameters: [toAddress, amount] as [AnyObject],
168
+
extraData: Data(),
169
+
transactionOptions: options)!
170
+
```
171
+
172
+
##### Write Transaction and call smart contract method
173
+
174
+
```swift
175
+
let value: String="0.0"// Any amount of Ether you need to send
176
+
let walletAddress =EthereumAddress(wallet.address)!// Your wallet address
177
+
let contractMethod ="SOMECONTRACTMETHOD"// Contract method you want to write
178
+
let contractABI ="..."// Contract ABI
179
+
let contractAddress =EthereumAddress(contractAddressString)!
180
+
let abiVersion =2// Contract ABI version
181
+
let parameters: [AnyObject] = [...]() // Parameters for contract method
182
+
let extraData: Data =Data() // Extra data for contract method
183
+
let contract = web3.contract(contractABI, at: contractAddress, abiVersion: abiVersion)!
184
+
let amount = Web3.Utils.parseToBigUInt(value, units: .eth)
185
+
var options = TransactionOptions.defaultOptions
186
+
options.value= amount
187
+
options.from= walletAddress
188
+
options.gasPrice= .automatic
189
+
options.gasLimit= .automatic
190
+
let tx = contract.write(
191
+
contractMethod,
192
+
parameters: parameters,
193
+
extraData: extraData,
194
+
transactionOptions: options)!
195
+
```
196
+
197
+
#### Web3View example:
122
198
123
199
You can see how to our demo project: **WKWebView with injected "web3" provider**:
124
200
@@ -132,7 +208,7 @@ open ./web3swiftBrowser.xcworkspace
132
208
### Build from source:
133
209
134
210
- Clone repo
135
-
- Instal dependencies via `./carthage-build.sh --platform iOS` (temo workaround, foe of Carthage bug.For more details please look athttps://github.com/Carthage/Carthage/issues/3019#issuecomment-665136323)
211
+
- Instal dependencies via `./carthage-build.sh --platform iOS` (temp workaround, foe of Carthage bug.[For details please look at](https://github.com/Carthage/Carthage/issues/3019#issuecomment-665136323)
0 commit comments