web3swift
web3swift copied to clipboard
nodeError(desc: "transaction underpriced")
I make the transaction from json:
["object": {
data = 0x7ff36ab500000000000000000000000000000000000000000000000000034039a4aab0bf0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000dcafb08f535d986c72ac254fe0bb225ccc0f77fc00000000000000000000000000000000000000000000000000000000c44d75b900000000000000000000000000000000000000000000000000000000000000030000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000008f3cf7ad23cd3cadbd9735aff958023239c6a063000000000000000000000000831753dd7087cac61ab5644b308642cc1c33dc13;
from = 0xdcafb08f535d986c72ac254fe0bb225ccc0f77fc;
gas = 0x50315;
to = 0xa5e0829caced8ffdd4de3c43696c57f7d7a678ff;
value = 0x16345785d8a0000;
}, "name": signTransaction, "id": 1646704788011]
` TransactionOptions(to: Optional(web3swift.EthereumAddress(_address: "0xa5e0829caced8ffdd4de3c43696c57f7d7a678ff", type: web3swift.EthereumAddress.AddressType.normal)), from: Optional(web3swift.EthereumAddress(_address: "0xdcafb08f535d986c72ac254fe0bb225ccc0f77fc", type: web3swift.EthereumAddress.AddressType.normal)), gasLimit: Optional(web3swift.TransactionOptions.GasLimitPolicy.manual(328469)), gasPrice: Optional(web3swift.TransactionOptions.GasPricePolicy.manual(1845490560)), value: Optional(100000000000000000), nonce: Optional(web3swift.TransactionOptions.NoncePolicy.latest), callOnBlock: Optional(web3swift.TransactionOptions.CallingBlockPolicy.pending))
Transaction Nonce: 68 Gas price: 1845490560 Gas limit: 328469 To: 0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff Value: 100000000000000000 Data: 0x7ff36ab500000000000000000000000000000000000000000000000000034039a4aab0bf0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000dcafb08f535d986c72ac254fe0bb225ccc0f77fc00000000000000000000000000000000000000000000000000000000c44d75b900000000000000000000000000000000000000000000000000000000000000030000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000008f3cf7ad23cd3cadbd9735aff958023239c6a063000000000000000000000000831753dd7087cac61ab5644b308642cc1c33dc13 v: 1 r: 0 s: 0 Intrinsic chainID: Optional(137) Infered chainID: Optional(1) sender: nil `
// Polygon Mainnet
let web333 = web3(provider: Web3HttpProvider(URL(string: "https://polygon-mainnet.g.alchemy.com/v2/X7YSnkDc6on7md1Tabt2ECssPYtJ4wCm")!, network: Networks.Custom(networkID: BigUInt(137)))!)
let options = TransactionOptions.fromJSON(dic)
var transaction = EthereumTransaction.fromJSON(dic)
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
transaction.UNSAFE_setChainID(BigUInt(137))
let result = try web333.eth.sendTransaction(transaction, transactionOptions: options, password: password)
@skywinder @BaldyAsh
Hello?
A number of changes have been made around Transactions since this was posted. Unfortunately the fromJSON functions were prematurely removed from the API along the way. (Though I've now restored them in #558)
Can you try testing now using #558 as your base, to see if the issue has been resolved? Barring any issues, the PR should be merged in early next week with the next 2.x release.
If you use SPM you can repoint it to use the PR temporarily for testing:
.package(url: "https://github.com/skywinder/web3swift.git", branch: "pull/558/head")