I have read that the gas cost of transfer function is 2300Ether. I have got the following contract having a function, testFunc(…), only containing transfer method as shown below, because I want to calculate the cost of 'transfer' function:

pragma solidity ^0.5.1;
contract TransferCost{
   uint public testVal = 97 ether;
   function testFunc(address payable addr) public {
   function deposit() payable public{}

When I am estimating the cost of the testFunc() function using truffle console, I am not getting 2300 instead I am getting 32201.

Truffle(development)> TGC= await TransferCost.new()

truffle(development)>  balance = await web3.eth.getBalance(TGC.address)
truffle(development)>  web3.utils.fromWei(balance, "ether")

truffle(development)> await web3.eth.getGasPrice()

truffle(development)> await TGC.testFunc.estimateGas('0x515f013CfC0B1beA8C4B95Baa438258EA1D81eeA')

Somebody please guide me how can we calculate the cost of Solidit's 'transfer' function to be 2300 Ether?


  • It's not 2300 Ether, but 2300 Wei.
    – hrkrshnn
    Feb 18, 2021 at 11:22

1 Answer 1


estimateGas estimates the cost of the whole transaction, not just one line of code.

For better understanding how gas cost work, I suggest you study the generated EVM bytecode and then you can even map each VM instruction to its cost by hand.

  • how to find out the cost of each VM instruction?Zulfi.
    – zak100
    Feb 19, 2021 at 5:49
  • The are in the Ethereum whitepaper, or you can just check from the source code of nodes. Feb 19, 2021 at 10:43
  • 1
    I recommend the Yellow Paper, Appendix G. Fee Schedule
    – pwagner
    Mar 9, 2021 at 2:18

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.