When I try to call function check()
with a number greater than 9007199254740991 I get an error:
Error encoding arguments: Error: Assertion failed
contract C {
function rateCheck(uint rate){
if(rate % 10 finney != 0 || rate == 0){
throw;
}
}
}
Question:
What's the best workaround?
Best Answer
Summary
geth
, solidity and the web3 interface is in wei.Your code is trying to perform that following conditional check
web3.toWei("999999999999999", "ether")
Details
Your issue is not with the large number.
Following is the code to test whether the large number is causing the problem:
Here is the Browser Solidity screen showing that your number will be accepted via the web browser commands:
And I tried interacting with the contract through the
geth console
command line:Following is the screenshot that demonstrates that the problem is likely to be around the
%
operator:Following is the Browser Solidity screen showing that your function works correctly - provided you pass the right units. And because the number is large, I had to enclose it in double quotes so the JavaScript interpreter passes the number as a BigNumber.
Here is a check from the
geth console
command line: