错误:无效的 BigNumber 值(参数 =“值”,值 = {“值”:“25000000000000000”},代码 = INVALID_ARGUMENT,版本 = bignumber/5.5.0)

Meg*_*yte 7 ethereum solidity smartcontracts metamask ethers.js

我尝试将值从 0.025 以太更改为 1 以太,然后也显示相同的错误。

另外,我尝试过像 1/8 这样的有理数仍然不起作用。

查看了一些答案,但他们没有解决错误。

我在其他项目中有相同的代码并且它在那里工作。

我收到的错误

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')
Run Code Online (Sandbox Code Playgroud)

错误图像 [1] [2]

这是我的上市价格代码

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

function getListingPrice() public view returns (uint256) {
        return listingPrice;
    }
Run Code Online (Sandbox Code Playgroud)

这是在 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

  }
Run Code Online (Sandbox Code Playgroud)

如果需要更多详细信息,请评论。

小智 1

我也遇到这个错误。就我而言,我忘记更新 ABI。