1

I'm running Hardhat and testing with Metamask and found something strange in the Hardhat console output. This happens when I go to Metamask and select my contract's token, then click "send", then enter the destination address, at this point Metamask calls my Hardhat node's eth_estimateGas function:

eth_estimateGas
  Contract call:       mycontract#transfer
  From:                0x0000.....
  To:                  0x0000.....
  Value:               0 ETH

  Error: VM Exception while processing transaction: reverted with reason string 'Invalid amount'
      at mycontract.someFunction (contracts/mycontract.sol:584)
      at mycontract.transfer (contracts/mycontract.sol:603)

As you can see it calls my transfer function, which checks the amount and reverts with "Invalid amount" if it's zero, which it is because I haven't entered the amount to transfer yet in Metamask.

What I don't understand is why it's calling mycontract.someFunction also. This is an external function that is never called anywhere in mycontract.

If I change the function name of someFunction then a different function is called instead. Maybe it's just calling the first function in the bytecode or something. I don't understand this behaviour, can someone enlighten me?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.