2

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) {
      addr.transfer(testVal);
      return testVal;
   }
   function deposit() payable public{}
}

I did the following:

TGC = await TransferGC.at('0xE4F90Ef2e5815cf24eea956b1f5781601859cb90')
truffle(development)> await web3.eth.getGasPrice()
'20000000000'
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.

Zulfi.

4

You need to change the syntax of this line:

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

into:

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, privacy policy and cookie policy

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