3
    const domainSeparator = {
        chainId: 5
    };
    
    const TestInfo = [
        { name: 'contractAddress', type: 'address' },
        { name: 'fee', type: 'uint256' }
      ];

    const data = {
        contractAddress: '.....',     
        airdropFee: 52009946125155410 // wei value
    };
    
    const signature = await signer._signTypedData(domainSeparator, { TestInfo }, data);

reason: 'overflow', code: 'NUMERIC_FAULT', fault: 'overflow', operation: 'BigNumber.from', value: 52009946125155410

solidity function takes uint256 wei value for weth amount as an argument, so I'm sending that number but getting overflow error. How do I fix that?

1 Answer 1

4

Your value 52009946125155410 is above the maximum integer safely representable as a Number type in JavaScript: 9007199254740991 so ethers.js throws an error.

Just pass it as a string :

airdropFee: "52009946125155410" // wei value

And it should be fine.

1
  • unbelievable, thanks it was so simple!
    – bbusdriver
    Apr 30, 2022 at 16:42

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.