Open simibac opened 3 years ago
Replace both .then with .map and delete .promise at the return statement.
This piece of code is working.
firstly {
web3.eth.getTransactionCount(address: privateKey.address, block: .latest)
}.then { nonce -> Promise<EthereumSignedTransaction> in
let tx = try EthereumTransaction(
nonce: nonce,
gasPrice: EthereumQuantity(quantity: 21.gwei),
gas: 21000,
to: EthereumAddress(hex: toAddress, eip55: true),
value: EthereumQuantity(quantity: BigUInt(10000000000000000))
)
return try tx.sign(with: privateKey, chainId: 3).promise
}.then { tx in
web3.eth.sendRawTransaction(transaction: tx)
}.done { hash in
print(hash.hex())
}.catch { error in
print(error)
}
Running the code snippet from the README for sending an ETH tx fails:
Error for
web3.eth.getTransactionCount(address: privateKey.address, block: .latest)
:and for
}.then { nonce in
:I am using Xcode 12.2, Web3 (0.5.3), PromiseKit(6.13.3)