I made ERC20 token.
And I am going to implement to send token using web3.py.
Here I want to calculate gas price and gas limit using token transaction.
If anyone know about that, please help me.


1 Answer 1


You will need to call web3 estimateGas function with the following parameters:

from: <sender public address>
to: <recipient public address>
data: <data>

The transaction fee is calculated based on what data is required. In your case, the method decimals() and transfer() is called to interact with your ERC20 standard token contract.

After acquiring the gas estimation, use web3 getGasPrice() function to get median gas price used in the last block. Multiply estimated gas and median gas price, you should be able to get your estimated transaction fee in wei format. Use web3.utils.fromWei to convert it to eth denomination.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.