I checked the following link: how to estimate gas cost?

My contract is:

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

I did the following:

TGC = await TransferGC.at('0xE4F90Ef2e5815cf24eea956b1f5781601859cb90')
truffle(development)> await web3.eth.getGasPrice()
await TGC.testFunc('0x3e1D6ef576d19A6D28f3755acDb754E37aFe6E4A').estimateGas(1)

I am getting the following error:

Thrown: TypeError: TGC.testFunc(...).estimateGas is not a function

Somebody please guide me.


1 Answer 1


You need to change the syntax of this line:

await TGC.testFunc('0x3e1D6ef576d19A6D28f3755acDb754E37aFe6E4A').estimateGas(1)


await TGC.testFunc.estimateGas('0x3e1D6ef576d19A6D28f3755acDb754E37aFe6E4A')

Because the arguments should go within the estimateGas method. For more information about the estimateGas method, check the documentation on truffle.

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.