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

Bug in uint256 type check? doesn't allow numbers over ~100e14 #1936

Closed
mjdietzx opened this issue Sep 12, 2018 · 5 comments
Closed

Bug in uint256 type check? doesn't allow numbers over ~100e14 #1936

mjdietzx opened this issue Sep 12, 2018 · 5 comments

Comments

@mjdietzx
Copy link

tokenSale.deploy({ data, arguments: [params.openingTime, params.closingTime, params.rate, params.wallet, 100e14, params.token, params.goal] }).send({
   from: '0xdeadbeef',
   gas: 5000000,
   gasPrice: 10e9,
}).then(console.log);

fails with:
Uncaught Error: invalid number value (arg="_cap", coderType="uint256", value=10000000000000000)

tokenSale.deploy({ data, arguments: [params.openingTime, params.closingTime, params.rate, params.wallet, 100e13, params.token, params.goal] }).send({
   from: '0xdeadbeef',
   gas: 5000000,
   gasPrice: 10e9,
}).then(console.log);

passes as normal (and any values smaller than 100e13

@mjdietzx
Copy link
Author

It looks like this isn't a problem with web3. I think it's due to MetaMask/metamask-extension#2350

I'm using MetaMask as web3 provider and I was using "web3": "^1.0.0-beta.36". So i downgraded to 0.2.0 which MetaMask requires and it works now. I only see this problem for deploying functions with large uint256 arguments in constructor

@mjdietzx mjdietzx reopened this Sep 13, 2018
@mjdietzx
Copy link
Author

screen shot 2018-09-13 at 3 14 49 pm

My above comment, downgrading web3js deployed the contract. Then I realized all the arguments were set to "3.963877391197344453575983046348115674221700746820753546331534351508065746944e+75"

@mjdietzx
Copy link
Author

Ah, number inputs need to be in hex format:

const { toHex } = web3.utils;
const arguments = [toHex(params.openingTime), ...]

@wigy-opensource-developer
Copy link

wigy-opensource-developer commented Sep 26, 2018

@mjdietzx Where did you get the info that all number inputs need to be in hex? In 1.0.0-beta34 we could send bignumber decimal strings into web3 without any problems. In 1.0.0-beta.36 there is this extra heuristic added that prevents us to send higher bignumbers to the API. So what piece of documentation or announcement did we miss?

@SalahAdDin
Copy link

@wigy-opensource-developer Look at this: #2077

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants