|
32 | 32 | - [Send ERC-20 Token](#send-erc-20-token)
|
33 | 33 | - [Write Transaction and call smart contract method](#write-transaction-and-call-smart-contract-method)
|
34 | 34 | - [Read Transaction to call smart contract method](#read-transaction-to-call-smart-contract-method)
|
| 35 | + - [Other Transaction Types (EIP-1559)](#other-transaction-types) |
35 | 36 | - [Send Transaction](#send-transaction)
|
36 | 37 | - [Write](#write)
|
37 | 38 | - [Read](#read)
|
@@ -355,6 +356,40 @@ let result = try! transaction.send(password: password)
|
355 | 356 | let result = try! transaction.call()
|
356 | 357 | ```
|
357 | 358 |
|
| 359 | +##### Other Transaction Types |
| 360 | + |
| 361 | +By default a `legacy` transaction will be created which is compatible accross all chains, regardless of which fork. |
| 362 | +To create one of the new transaction types introduced with the `london` fork you will need to set some additonal parameters |
| 363 | +in the `TransactionOptions` object. Note you should only try to send one of tehse new types of transactions if you are on a chain |
| 364 | +that supports them. |
| 365 | + |
| 366 | +To send an EIP-2930 style transacton with an access list you need to set the transaction type, and the access list, |
| 367 | +in addition what is shown in the eexamples above |
| 368 | +```swift |
| 369 | +let accessList: [AccessListEntry] = [ |
| 370 | + AccessListEntry( |
| 371 | + address: EthereumAddress("0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae"), |
| 372 | + storageKeys: [BigUInt(3), BigUInt(7)] |
| 373 | + ), |
| 374 | + AccessListEntry( |
| 375 | + address: EthereumAddress("0xbb9bc244d798123fde783fcc1c72d3bb8c189413"), |
| 376 | + storageKeys: [] |
| 377 | + ) |
| 378 | +] |
| 379 | + |
| 380 | +options.type = .eip2930 |
| 381 | +options.accessList = accessList |
| 382 | +``` |
| 383 | + |
| 384 | +To send an EIP-1559 style transaction you set the transaction type, and the new gas parameters `maxFeePerGas` and `maxPriorityFeePerGas` |
| 385 | +(you may also send an AccessList with an EIP-1559 transaction) When sending an EIP-1559 transaction, the older `gasPrice` parameter is ignored. |
| 386 | +```swift |
| 387 | +options.type = .eip1559 |
| 388 | +options.maxFeePerGas = .manual(...) // the maximum price per unit of gas, inclusive of baseFee and tip |
| 389 | +options.maxPriorityFeePerGas = .manual(...) // the tip to be paid to the miner, per unit of gas |
| 390 | +``` |
| 391 | +Note there is a new `Oracle` available that can be used to assist with estimating the new gas fees |
| 392 | + |
358 | 393 | ### Chain state
|
359 | 394 |
|
360 | 395 | #### Get Block number
|
|
0 commit comments