Skip to content

Commit 6bb47dd

Browse files
committed
added some basics for creating transactions with the new types
1 parent 7424336 commit 6bb47dd

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Documentation/Usage.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- [Send ERC-20 Token](#send-erc-20-token)
3333
- [Write Transaction and call smart contract method](#write-transaction-and-call-smart-contract-method)
3434
- [Read Transaction to call smart contract method](#read-transaction-to-call-smart-contract-method)
35+
- [Other Transaction Types (EIP-1559)](#other-transaction-types)
3536
- [Send Transaction](#send-transaction)
3637
- [Write](#write)
3738
- [Read](#read)
@@ -355,6 +356,40 @@ let result = try! transaction.send(password: password)
355356
let result = try! transaction.call()
356357
```
357358

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+
358393
### Chain state
359394

360395
#### Get Block number

0 commit comments

Comments
 (0)