I want to send big value (10000000) for example to other wallet but i have error like this:

 UnhandledPromiseRejectionWarning: Error: Error: [number-to-bn] while converting number 3.0244e+22 to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported. Given value: "3.0244e+22"

My code:

 const myAddress = web3.eth.defaultAccount;
      const gasPrice = new BN(await web3.eth.getGasPrice()).mul(new BN(toSend));
      const gasLimit = 6721900;
      const value = toSend* 1e18; 
      const from = web3.eth.defaultAccount;
      const to = wallet_id; 
  • "new BN(await web3.eth.getGasPrice()).mul(new BN(toSend))" why are you using .mul here? what is "toSend" and what is the purpose of .mul?
    – Majd TL
    Commented Apr 13, 2022 at 14:08
  • and value should probably: const value = new BN("1000000000000000000").mul(new BN(toSend));
    – Majd TL
    Commented Apr 13, 2022 at 14:09

1 Answer 1


if you use ether.js you can do it easy like that : ethers.utils.parseEther('1') || ethers.utils.parseEther('0.01') ||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.