1

I am following contracts documentation at https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend

And got to the point where my contract call looks something like this (someMethod and someArgument are irrelevant placeholder values)

      contract.someMethod(someArgument, {
        gasLimit: 100000,
        maxPriorityFeePerGas: 5,
        maxFeePerGas: 200,
        value: 0.7
      })

Executing this method I am getting all sorts of errors like

underflow

processing response error

I'm not sure why I am getting these, but I think its due to my options that I pass to the contract, they might be in the wrong format? I tried to find docs on how to format these correctly, but had no success. At the moment I am following same input format as in MetaMask extension

1 Answer 1

2

The values maxPriorityFeePerGas, maxFeePerGas and value should be in Wei (the smallest unit on Ethereum). You can use Ethers.js' parseUnits to convert a value in Gwei or Ether to Wei:

contract.someMethod(someArgument, {
  gasLimit: 100000,
  maxPriorityFeePerGas: ethers.utils.parseUnits('5', 'gwei'),
  maxFeePerGas: ethers.utils.parseUnits('200', 'gwei'),
  value: ethers.utils.parseUnits('0.7') // 'ether' is the default
});
0

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.