3

I defined my method as: (for simplicity)

function exampleOfPassingWeiAsArgument(uint amount) public returns (uint roundId) {
    // More than 0.01 ETH
    require(amount > 10000000000000000);
}

But when I pass the following value using remix UI: "11000000000000000",

I get the following error:

Error encoding arguments: Error: Assertion failed

When I pass one zero less: "1100000000000000" it gets through but I crash obviously due to the "require" check as I am sending too few amount in Wei:

The transaction has been reverted to the initial state.

BTW: I am not trying to perform a transfer just pass Wei amount of ether as a function argument.

Any idea why I can't pass uint 11000000000000000 ?

2

Remix hates large numbers and addresses.

For some reason the remix UI has problems with big numbers and addresses.

I find that any big numbers, or addresses I enter into the text boxes will need to be quoted when I put them into the remix UI:

remix-large-number.png

This is bizarre as the Javascript console itself and JSON.parse() don't seem to have any issues with numbers this big.

However with remix once the number is quoted it will work properly, just like magic.

3
  • Aaaaaaaaaaaah and I thought I am crazy or don't understand how Wei and uint works... thx man. Works like a charm. I wanted to raise/fix the issue so I just checked Github and the issue is already addressed by someone else actually. Mar 19 '18 at 8:19
  • Yeah, it got me at the beginning too. I initially thought it was something to do with javascript and exceeding the 32 bit signed integer size... but even with one less zero, it's still way bigger than 2.1bn.
    – norganna
    Mar 19 '18 at 9:06
  • I also didn't see any error in the console so I was like... must be doing something wrong haha. Mar 19 '18 at 9:21

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.