const result = await myContract.methods.myMethod(1).call();

brings the error from above. There is a simmilar questions here but since I use call gas shouldn't matter. I'm using "web3": "1.0.0-beta.35", (Beta.36 doesn't work for me at all.)

  • Use 1.0.0-beta.34 or 1.0.0-beta.37 or (best) 1.2.x (which relies on beta37 AFAIK). – goodvibration Nov 28 '19 at 10:38

Are you using Quorum? If you are, this is probably because you are using RAFT consensus algorithm, you have to amend web3 or change to IBFT

|improve this answer|||||

That is Javascript integer limitation (Number.MAX_SAFE_INTEGER).

In order to work-around it, pass a String or as BigNumber instead.

For example:

const result = await myContract.methods.myMethod("1000000000000000000000").call();
const result = await myContract.methods.myMethod(new BigNumber(2).pow(54)).call();
|improve this answer|||||
  • In this case, await myContract.methods.myMethod("1").call(); – user19510 Sep 20 '18 at 17:26
  • @smarx: Yes, of course, but I don't see how this case (or any other case for that matter) could yield the error at the title. I guess he's doing something with the returned value which eventually causes this error (something which he hasn't posted here). – goodvibration Sep 20 '18 at 17:27
  • So you believe your answer is incorrect? – user19510 Sep 20 '18 at 17:30
  • I don't do anything with the answer. I also tried with a sting or BigNumber but without success. As a workaround I'm using truffle-contract now which works fine. – MarcS82 Sep 20 '18 at 17:49
  • @smarx: No, I believe that the question is missing some info. Either that, or there's a serious bug in "web3": "1.0.0-beta.35", which I sincerely doubt (though I've been using 34 for quite some time, so I'm possibly wrong on that one). – goodvibration Sep 20 '18 at 19:58

This will also happen if you set gasPrice to be some very large value when sending transaction like: 15e64.

|improve this answer|||||

In many blogs I've found it was a Truffle version problem. Truffle v5 would make problems of this type. They suggest to downgrade to truffle@4.1.15.

This has not been so for me. I have continue to use truffle v5. I've resolved by checking my gas limit when I sent a transaction. gasLimit: web3.utils.toHex( gas_limit ),//The maximum gas provided for this transaction (gas limit)

Node: v8.11.4 Truffle: 5.0.12 Web3: 1.0.0-beta.52 Truffle-contract: 4.0.11 Truffle-interface-adapter@0.1.2 │ └── web3@1.0.0-beta.37 └── web3@1.0.0-beta.37 Ganache-cli: v6.4.3 (ganache-core: 2.5.5) Ethereumjs-tx: 1.3.4

|improve this answer|||||

Check the contract code again please, You may have added some require(msg.sender == owner) like modifier and you code doesn't return some data which can be processed in client side.

|improve this answer|||||

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.