Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 794
Megabyte Avatar asked Jul 29 '26 12:07

Megabyte


1 Answers

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

like image 128
Liam Pillay Avatar answered Aug 02 '26 08:08

Liam Pillay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!