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 {
addr.transfer(testVal);
}
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()
undefined
:
:
truffle(development)> balance = await web3.eth.getBalance(TGC.address)
undefined
truffle(development)> web3.utils.fromWei(balance, "ether")
'194'
truffle(development)> await web3.eth.getGasPrice()
'20000000000'
truffle(development)> await TGC.testFunc.estimateGas('0x515f013CfC0B1beA8C4B95Baa438258EA1D81eeA')
32201
Somebody please guide me how can we calculate the cost of Solidit's 'transfer' function to be 2300 Ether?
Zulfi.