I'm encountering an issue while executing the code below. The code is intended to call the quoteExactOutputSingle function from a contract named Quoter. However, I'm getting an error related to an invalid BigNumber value.

const { Contract, ethers } = require("ethers");
const fs = require("fs");
// Connect to the Ethereum mainnet via Infura
const RPC_URL = 'ws://';
const provider = new ethers.providers.WebSocketProvider(RPC_URL);

// Define the Quoter contract address and ABI
const QUOTER_ADDRESS = "0x61fFE014bA17989E743c5F6cB21bF9697530B21e";
const quoter_addy = new Contract(QUOTER_ADDRESS, JSON.parse(fs.readFileSync("./QuoterV2ABInew.json")), provider);

const contractAddress = '0xf8c76dbea329ec4fa987afc514f805b21b249d79';
const desiredAmount = ethers.utils.parseUnits("1000000", 18); // 1000000000000000000000000000
const from = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
const fee = 10000;
const sqrtPriceLimitX96 = "0";

async function getAmountOut() {
    const params = {
        'tokenIn': from,
        'tokenOut': contractAddress,
        'fee': fee,
        'amountOut': desiredAmount,
        'sqrtPriceLimitX96': '0'
    try {
        const ret = await quoter_addy.callStatic.quoteExactOutputSingle(params);
        return [ret[0], ret[3]];
        // we catch an error because the pool may not exist
    } catch (error) {
        return [null, null];


When executing the code, I receive the following error message:

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

I'm unsure how to resolve this error. Could someone please help me understand what might be causing this issue and how I can fix it?

1 Answer 1

    struct QuoteExactOutputSingleParams {
        address tokenIn;
        address tokenOut;
        uint256 amount;
        uint24 fee;
        uint160 sqrtPriceLimitX96;

The parameter names and order need to follow the defined struct.

  const params = {
    tokenIn: from,
    tokenOut: contractAddress,
    amount: desiredAmount,
    fee: fee,
    sqrtPriceLimitX96: "0",

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.