Ethereum Fee estimate, insufficient funds and GasPrice

Modified on Thu, 25 May 2023 at 08:37 AM

TABLE OF CONTENTS


When building a transaction with Ethereum, a common pitfall in using manual fees is adding gasPrice in Wei instead of Gwei. When this happens, you will likely get an error.


Example error:

ERROR: { statusCode: 403, errorCode: 'eth.tx.preparation', message: 'Transaction preparation failure.', cause: 'Insufficient funds send transaction from account 0xBF5c7e33a316cf7D86eBF4014bCf798c6962#### -> available balance is 1800000000000000, required balance is 7.233615778886385e+23' }

Ethereum Fee Estimate

Tatum Fee estimates endpoints return values in Wei.


Example ETH Fee Estimate:

curl --location 'https://api.tatum.io/v3/ethereum/gas' \
--header 'Content-Type: application/json' \
--header 'x-api-key: ##Mainnet_API_KEY' \
--data '{
    "from": "0xBF5c7e33a316cf7D86eBF4014bCf798c6962####",
    "to": "0xce864aaec47f07ee8ba7e60a37ff141298f7####",
    "amount": "0.018"
}'
//response:
{
    "gasLimit": "21000",
    "gasPrice": "43698096524", //unit in Wei
    "estimations": {
        "safe": "43698096524",
        "standard": "43698096524",
        "fast": "43698096524",
        "baseFee": "43914769922"
    }
}
API documentation is available at the following link.

Sending Ethereum with manual fees

When creating an Ethereum transaction, if you want to input the transaction fee manually, make sure the gasPricea in Gwei


1 Gwei (Giga-wei) is equal to 1,000,000,000 Wei. Therefore, to convert Wei to Gwei, you have to divide the amount in Wei by 1,000,000,000. Alternatively, you may use an online conversion such as eth-converter.com 


Example of ETH transaction with Manual Fees:

curl --location 'https://api.tatum.io/v3/ethereum/transaction' \
--header 'Content-Type: application/json' \
--header 'x-api-key: ##Mainnet_API_KEY' \
--data '{
    "to": "0xd2c4b6434410e4af062ee3c280327c8ece11####",
    "currency": "ETH",
    "amount": "0.0017",
    "fromPrivateKey": "****",
    "fee": {
        "gasLimit": "21000",
        "gasPrice": "34" //unit in Gwei
    }
}'


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article