【问题标题】:ethers js exits with this error=> invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.5.0)ethers js 退出并出现此错误=> 无效的 BigNumber 值(argument="value",value=undefined,code=INVALID_ARGUMENT,version=bignumber/5.5.0)
【发布时间】:2021-11-04 16:35:58
【问题描述】:

我尝试使用 ethersjs 向我的合约发送请求,如下所示:

        const web3Modal = new Web3Modal()
        const connection = await web3Modal.connect()
        const provider = new ethers.providers.Web3Provider(connection)
        const signer = provider.getSigner()
        const contract = new ethers.Contract(Contract, Market.abi, signer)
        const price = ethers.utils.parseUnits(price.toString(), 18)

       //const price = web3.utils.toWei(nft.price);
        //const price = ethers.BigNumber.from(nft.price.toString()).toHexString();
       
        const transaction = await contract.createSale(address, price)
        
        await transaction.wait()

此代码显示错误,我尝试了世界上所有的解决方案,但没有任何效果。 => 版本:nodejs 14.15、npm 8、web3 1.6、ethers 5.5

有什么帮助吗?

错误:未处理的拒绝(错误):无效的 BigNumber 值(argument="value",value=undefined,code=INVALID_ARGUMENT,version=bignumber/5.5.0)

【问题讨论】:

    标签: web3 web3js metamask ethers.js


    【解决方案1】:

    当您调用createSale 时,您的价格变量的值似乎undefined,从而导致错误。

    您的问题类似于:https://ethereum.stackexchange.com/questions/111042/cant-send-ether-to-smart-contract-using-ethers-js

    【讨论】:

      猜你喜欢
      • 2022-08-14
      • 2022-12-04
      • 2021-12-28
      • 2023-02-15
      • 1970-01-01
      • 2021-07-28
      • 2022-06-27
      • 2020-12-21
      • 2021-03-16
      相关资源
      最近更新 更多