1
votes

I am building an ERC20 Token. I have used the decimals properly. So, I am transfering 10^21 tokens to a function to transfer my token.

Minted tokens : 1000000 * (10**decimals) # decimals = 18

So I should be able to transfer this amount?

I made a UI and used web3.js where I got this error.

Unhandled Rejection (Error): 
invalid number value (arg="_price", coderType="uint256", value="1e+21")

Then I also tried in Remix for the same values. there also the transaction failed. Execution is failing for numbers like if I want to transfer 10*20 token. then also the transaction fails.

Thanks for the help.

1

1 Answers

2
votes

Solved it using this: https://github.com/ethereum/web3.js/issues/2077#issuecomment-468530879

          const dec = window.web3.utils.toBN(this.props.decimals)
          const price_ =  window.web3.utils.toBN(this.Object.value*(100))
          const price ="0x"+ price_.mul(window.web3.utils.toBN(10).pow(dec)).toString("hex")