I know that if my contract has a name() method. I can go to the truffle console and try


and this will give the estimate gas for that method.

but what if have a receive method inside my contract to take ether:

receive() external payable {

and I wanna know it's gas. Then what is the correct syntax?

I've tried:


as I thought as receive is the default function for ether payment. But didn't work.


this doesn't work either.

can I get some help?

1 Answer 1


It doesn't seem there's a specific call to estimateGas of the fallback/receive function. You could use web3's estimateGas

  to: contract.address,
  data: "0x",
  • Yes, you're right. I also started a discussion on their Github and then one of their maintainers created an issue for this feature request. Hope it's added soon. The issue link is here. Jul 30, 2022 at 5:05

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.