I'm just trying to transfer from one of my smart contracts in Ropsten to my wallet 1.02 WETH with this line

const deposit = weth.methods.transferFrom(contract,wallet,1020000000000000000).send({from:wallet}).then(console.log)

But I'm getting this error:

Error: overflow (fault="overflow", operation="BigNumber.from", value=1020000000000000000, code=NUMERIC_FAULT, version=bignumber/5.3.0)

The amount has a precision of 18 decimals, and if I'm not mistaken that should be correct, right?


1 Answer 1


The problem is that javascript numbers do not have enough precision.

Use web3.utils.toBN to wrap them in a BigNumber object

const amount = web3.utils.toBN("1020000000000000000")
const deposit = weth.methods.transferFrom(contract,wallet,amount).send({from:wallet}).then(console.log)

Since they are ether amounts perhaps it is better to use web3.utils.toWei

const amount = web3.utils.toWei("1.02", "ether")

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.