[Ethereum] Why “Insufficient funds” error

balancesfeesgasgas-pricetransactions

I'm trying to send a transaction into testnet from an account having a balance of 516,561,000 Babbages. According to my calculations, this is exactly the cost of the transaction to perform. Nevertheless result is always "Insufficient funds for gas * price + value".

This is the transaction I want to send:

eth_sendTransaction: [{
    "from": "0xa7e3c7c227c72a60e5a2f9912448fb1c21078769",
    "to": "0x6861973632a44775a0dae132ef4578a95fcebd6c",
    "value": "1000000000",
    "gasPrice": "20000000000",
    "nonce": "0x100000",
    "data": "0x4d61726b65745061792e696f202d2041756469744c6f673a204175646974206c6f672074782066726f6d206a75616e20746f20616c656a616e64726f206f662031206575726f73"
}]

result => Insufficient funds for gas * price + value

This is the estimated gas calculation for this transaction:

eth_estimateGas: [{
    "from": "0xa7e3c7c227c72a60e5a2f9912448fb1c21078769",
    "to": "0x6861973632a44775a0dae132ef4578a95fcebd6c",
    "value": "1000000000",
    "data": "0x4d61726b65745061792e696f202d2041756469744c6f673a204175646974206c6f672074782066726f6d206a75616e20746f20616c656a616e64726f206f662031206575726f73"
}]

result => 0x64e4 // gasEstimated = 25828

And this is the medium price of the gas:

eth_gasPrice: []

result => 0x4a817c800 // 20000000000 (gasPrice medium = 20,000 Babbages)
)

So,

txFeeEstimated = gas * price = 516,560,000 Babbages

Minimal funds = gas * price + value = 516,561,000 Babbages

And according to https://testnet.etherscan.io/address/0xa7e3c7c227c72a60e5a2f9912448fb1c21078769

The ETH Balance is 0.000516561 Ether

Why the error? Is not balance = gas * price + value in this case?

Best Answer

Can you force the gas:

eth_sendTransaction: [{
    "from": "0xa7e3c7c227c72a60e5a2f9912448fb1c21078769",
    "to": "0x6861973632a44775a0dae132ef4578a95fcebd6c",
    "value": "1000000000",
    "gasPrice": "20000000000",
    "gas": "25828",
    "nonce": "0x100000",
    "data": "0x4d61726b65745061792e696f202d2041756469744c6f673a204175646974206c6f672074782066726f6d206a75616e20746f20616c656a616e64726f206f662031206575726f73"
}]

Otherwise you let the system send more than the estimated gas. Fingers crossed that this is indeed enough gas.

Related Topic