'Error: invalid BigNumber value (argument="value", value={"value":"25000000000000000"}, code=INVALID_ARGUMENT, version=bignumber/5.5.0)

I have tried changing the values from 0.025 ether to 1 ether then also its showing the same error.

Also, I have tried with the rational number like 1/8 still not working.

LOOKED into some answers but they didn't resolve the error.

I have the same code in other project and it's working over there.

Error Which I received

Uncaught (in promise) Error: invalid BigNumber value (argument="value", value={"value":"25000000000000000"}, code=INVALID_ARGUMENT, version=bignumber/5.5.0)

Could not get the stack frames of error: TypeError: Cannot read properties of null (reading 'length')

Image of the Error [1] [2]

Here is my Code for the Listing Price

    uint256 listingPrice = 0.025 ether ; // Here ether is denoting the MATIC

function getListingPrice() public view returns (uint256) {
        return listingPrice;
    }

Here is the Code for fetching the value in UI

async function putItem(url) {
    const web3Modal = new Web3Modal();
    const connection = await web3Modal.connect();
    const provider = new ethers.providers.Web3Provider(connection);
    const signer = provider.getSigner();

    const { royalty } = formInput;

    //NFT Contract
    let contract = new ethers.Contract(nftAddress, NFT.abi, signer);
    //minting the certificate
    let transaction = await contract.createToken(url);
    //waiting for the minting transaction to finish

    let tx = await transaction.wait();
    let event = tx.events[0];
    let value = event.args[2];
    let tokenId = value.toNumber(); //Token Id Of the NFT
    console.log(tokenId)

    //NFT Market Contract
    contract = new ethers.Contract(nftMarketAddress, NFTMarket.abi, signer);

    //fetching listing price from the contract
    let listingPrice = await contract.getListingPrice();
    listingPrice = listingPrice.toString();

    //listing the certificate. 
    transaction = await contract.createMarketItem(
      nftAddress,
      tokenId,
      { value: (listingPrice) },
      royalty,
      index
    );
    //waiting for the transaction to complete
    await transaction.wait();
    console.log("completed")

    //navigate back to home page

  }

If any more detail required, please comment.



Solution 1:[1]

It looks like you're trying to send an object as the parameter { value: (listingPrice) }

This should probably be written as either an array of parameters or just the listingPrice

//listing the certificate. 
transaction = await contract.createMarketItem(
  nftAddress,
  tokenId,
  listingPrice,
  royalty,
  index
);

Source: https://docs.ethers.io/v5/api/contract/contract/#contract-functionsSend

Solution 2:[2]

I got this error as well. In my case, I forgot to update the ABI.

Solution 3:[3]

You can use the following module:

import converter form "ethereum-uint-converter"

And if you want to know more detail, click here.

Solution 4:[4]

For my case I needed to add .toString() to the BigNumber before passing it to the contract.

async changePayoutAmount_ether(amount_ether) {
    let amount_wei = new BigNumber(amount_ether).shiftedBy(18).toString()
    await this.state.pcrContract.methods.setPayoutAmount(amount_wei).send({from: this.state.account}).then(console.log)
}

Also for anyone troubleshooting, note that there are at least two BigNumber libraries: I believe this error comes from this one but be careful if you're reading docs from the ethers.js one because the syntax for the constructors is different.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Liam Pillay
Solution 2 ouflak
Solution 3 ouflak
Solution 4 user3441246