Help please with: invalid number value (arg="amount", coderType="uint256"

Hi Z community!

This might be more web3 related (“web3”: “^1.0.0-beta.55”) but I hope I can ask here… I have simple reactjs web app (my first one ever) that does a transfer of tokens.

My contact (used ERC20.sol) uses 18 decimals.

When I try to send 1 token, I get this error:

Unhandled Rejection (Error): invalid number value (arg=“amount”, coderType=“uint256”, value=1000000000000000000, version=4.0.32)

or when using web3.utils.toBN:

Unhandled Rejection (Error): invalid number value (arg=“amount”, coderType=“uint256”, value=“de0b6b3a7640000”, version=4.0.32)

Any idea on how to get this to work or what I’m doing wrong here?

Thanks,
Steve

1 Like

Seems to be web3 issue: https://github.com/ethereum/web3.js/issues/2077

I did a workaround by changing my token amount to String:

numberOfTokensToSend.toString()

Transfer works now.

2 Likes

Glad you have found it. It remembered me on writing unit tests. uint256 arguments needs to be passed as string for BigNumber

2 Likes