Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ethers encoder errors when processing Web3 BN values (beta.36) #1920

Closed
cgewecke opened this issue Sep 5, 2018 · 7 comments
Closed

Ethers encoder errors when processing Web3 BN values (beta.36) #1920

cgewecke opened this issue Sep 5, 2018 · 7 comments
Labels
Bug Addressing a bug

Comments

@cgewecke
Copy link
Collaborator

cgewecke commented Sep 5, 2018

With a solidity method like:

function set(uint val) public {
  ..etc..
}

In beta.36this:

const val = web3.utils.toBN(1);
const data = myContract.methods.set(val).encodeABI();

throws this:

 Error: invalid number value (arg="val", coderType="uint256", value="1")
      at Object.throwError (/Users/cgewecke/code/consensys/e2e-beta36/wild-truffle/truffle/packages/truffle/build/webpack:/~/ethers/utils/errors.js:68:1)
      at CoderNumber.encode (/Users/cgewecke/code/consensys/e2e-beta36/wild-truffle/truffle/packages/truffle/build/webpack:/~/ethers/utils/abi-coder.js:353:1)
      at /Users/cgewecke/code/consensys/e2e-beta36/wild-truffle/truffle/packages/truffle/build/webpack:/~/ethers/utils/abi-coder.js:605:21

However this works:

const ethers = require('ethers');

const val = ethers.utils.bigNumberify(1);
const data = myContract.methods.set(val).encodeABI();
@gkaemmer
Copy link

gkaemmer commented Sep 7, 2018

This seems like a really big change to the web3 internals..is it better to use utils from ethers going forward?

@eyezick
Copy link
Contributor

eyezick commented Sep 30, 2018

Also getting this issue now when passing a BigNumber.js object directly. Breaking change.

 Error: invalid number value (arg="_tokenCap", coderType="uint256", value="300")
      at Object.throwError (node_modules/ethers/utils/errors.js:68:17)
      at CoderNumber.encode (node_modules/ethers/utils/abi-coder.js:353:20)
      at node_modules/ethers/utils/abi-coder.js:605:59

@justinkchen
Copy link

Maybe it is fixed in ethers.js 4.0.5? web3 beta.36 is still on ethers.js 4.0.1-beta.1

@shumailxyz
Copy link

shumailxyz commented Oct 18, 2018

Stuck at same issue. Was working fine on beta.34.
@eyezick can confirm too that passing a BigNumber object directly also breaks.

Is it related to #1936 (comment) ?
Somehow passing hex works for me too.

Tagging @nivida & @frozeman for input over this.

@nivida nivida added the Bug Addressing a bug label Oct 31, 2018
@alexpee
Copy link

alexpee commented Nov 1, 2018

Having the same issue, it works fine for Ganache but not working for Ropsten with Infura

@piesrtasty
Copy link

Any update to this?

@nivida
Copy link
Contributor

nivida commented Jan 22, 2019

Updated ethers to the latest version in PR #2000 and this should fix it. Otherwise please open an issue in the ethers.js repository.

@nivida nivida closed this as completed Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Addressing a bug
Projects
None yet
Development

No branches or pull requests

8 participants