I'm facing a problem who's driving me crazy

I'm trying to create a swap with this code :

my_tx = await routerV3.exactOutputSingle({
        tokenIn: '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6',
        tokenOut: '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984',
        fee: 3000,
        recipient: '0xc9391458c806d8906c8a67e7d9b868cb703a50cf',
        amountOut: 100000000000000,
        amountInMaximum: 70680341863192,
        sqrtPriceLimitX96: 0
        value: ethers.BigNumber.from(1000000),
        gasLimit: tx.gasLimit,
        maxFeePerGas: 50000000000,
        maxPriorityFeePerGas: 5000000000,
        type: 2

And I'm facing this error :

Error: invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.7.0)
    at Logger.makeError (/Users/tsarbuig/JsProjects/test/node_modules/@ethersproject/logger/lib/index.js:238:21)
    at Logger.throwError (/Users/tsarbuig/JsProjects/test/node_modules/@ethersproject/logger/lib/index.js:247:20)
    at Logger.throwArgumentError (/Users/tsarbuig/JsProjects/test/node_modules/@ethersproject/logger/lib/index.js:250:21)
    at Function.BigNumber.from (/Users/tsarbuig/JsProjects/test/node_modules/@ethersproject/bignumber/lib/bignumber.js:239:23)
    at NumberCoder.encode (/Users/tsarbuig/JsProjects/test/node_modules/@ethersproject/abi/lib/coders/number.js:36:39)
    at /Users/tsarbuig/JsProjects/test/node_modules/@ethersproject/abi/lib/coders/array.js:74:19
    at Array.forEach (<anonymous>)
    at pack (/Users/tsarbuig/JsProjects/test/node_modules/@ethersproject/abi/lib/coders/array.js:60:12)
    at TupleCoder.encode (/Users/tsarbuig/JsProjects/test/node_modules/@ethersproject/abi/lib/coders/tuple.js:71:33)
    at /Users/tsarbuig/JsProjects/test/node_modules/@ethersproject/abi/lib/coders/array.js:74:19 {
  reason: 'invalid BigNumber value',
  argument: 'value',
  value: undefined

As you can see:

  • I entered a value
  • but it's not recognized...

It's crazy because same code with exactInputSingle works perfectly...

Anyone has an idea why the value I enter in my swap is not recognized ?

Thanks a lot guys

1 Answer 1


Sometimes getting the correct format for ethers can be tough.

Two things to try:

Try using a string in the bignumber conversion ie ethers.BigNumber.from('1000000')


Try importing Bignumber separately

import { ethers, BigNumber } from "ethers";

and I believe ethers also requires the gasLimit, maxFeePerGas, and maxPriorityFeePerGas will need to be BN as well

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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