web3swift
web3swift copied to clipboard
nodeError(desc: "intrinsic gas too low")
I'm using Uniswap and WalletConnect to send transaction:
I made a transaction from json:
{"data":"0xc04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000e7a7fd7607dab86cb7680e606934098b33a2b42000000000000000000000000000000000000000000000000000000000610a3660000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000001584225329b4c81a50000000000000000000000000000000000000000000000000000000000000042c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f42260fac5e5542a773aa44fbcfedf7c193bc2c599000bb86b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000000000000",
"from":"0xe7a7fd7607dab86cb7680e606934098b33a2b420",
"gas":"0x429a0",
"to":"0xe592427a0aece92de3edee1f18e0157c05861564",
"value":"0x2386f26fc10000"}
My code:
guard var options = TransactionOptions.fromJSON(dic) else {
return
}
guard var transaction = EthereumTransaction.fromJSON(dic) else {
return
}
let walletAdd = EthereumAddress(walletAddress)
do {
let pendingNonce = try web333.eth.getTransactionCount(address: walletAdd!, onBlock: "pending")
let latestNonce = try web333.eth.getTransactionCount(address: walletAdd!, onBlock: "latest")
let selectedNonce = max(pendingNonce, latestNonce)
transaction.nonce = selectedNonce
let result = try web333.eth.sendTransaction(transaction, transactionOptions: options, password: password)
print(result)
print(result.hash)
} catch {
print(error)
}
TransactionOptions(
to: Optional(web3swift.EthereumAddress(_address: "0xe592427a0aece92de3edee1f18e0157c05861564", type: web3swift.EthereumAddress.AddressType.normal)),
from: Optional(web3swift.EthereumAddress(_address: "0xe7a7fd7607dab86cb7680e606934098b33a2b420", type: web3swift.EthereumAddress.AddressType.normal)),
gasLimit: Optional(web3swift.TransactionOptions.GasLimitPolicy.limited(272800)),
gasPrice: Optional(web3swift.TransactionOptions.GasPricePolicy.automatic),
value: Optional(10000000000000000),
nonce: Optional(web3swift.TransactionOptions.NoncePolicy.pending),
callOnBlock: Optional(web3swift.TransactionOptions.CallingBlockPolicy.pending))
Transaction
Nonce: 3
Gas price: 5000000000
Gas limit: 21000
To: 0xE592427A0AEce92De3Edee1F18E0157C05861564
Value: 10000000000000000
Data: 0xc04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000e7a7fd7607dab86cb7680e606934098b33a2b42000000000000000000000000000000000000000000000000000000000610a3660000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000001584225329b4c81a50000000000000000000000000000000000000000000000000000000000000042c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f42260fac5e5542a773aa44fbcfedf7c193bc2c599000bb86b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000000000000
v: 1
r: 0
s: 0
Intrinsic chainID: nil
Infered chainID: Optional(1)
sender: nil
hash: Optional("0x7d20eec1a76a19814b6fecaff8b8672568c4adf321d76aa0909e278f0f704834")
faced the same issue, I believe there is a bug in web3+options.swift
at the beginning of
public static func fromJSON(_ json: [String: Any]) -> TransactionOptions? {
there should be
if let gas = json["gas"] as? String, let gasBiguint = BigUInt(gas.stripHexPrefix().lowercased(), radix: 16) {
options.gasLimit = .manual(gasBiguint)
now it is set as limited, which is later replaced by default 21000...
Error: unauthorized: signature verification failed: deprecated support for homestead Signer