Fail with error ‘Value needs to be exactly the mint fee!‘

如图,调用合约,报这个错:

插代码:

    /**
    * @dev Mints a single token to an address.
    * fee may or may not be required*
    * @param _to address of the future owner of the token
    */
    function mintTo(address _to) public payable {
        require(onlyERC20MintingMode == false, "Only minting with ERC-20 tokens is enabled.");
        require(getNextTokenId() <= collectionSize, "Cannot mint over supply cap of 1000");
        require(mintingOpen == true && onlyAllowlistMode == false, "Public minting is not open right now!");
        
        require(canMintAmount(_to, 1), "Wallet address is over the maximum allowed mints");
        require(msg.value == getPrice(1), "Value needs to be exactly the mint fee!");
        
        _safeMint(_to, 1, false);
    }

问题出在这里: require(msg.value == getPrice(1), "Value needs to be exactly the mint fee!");

经过研究比较,发现是msg.value传大了,【说明,用的是测试网,测试网和主网的参数不一样,现在测试币不好弄,所以分别设置的,测试网地址:https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161

下面是web3调用代码:

        const func = await depositContract.mintTo(account, {
          value: web3.utils.toWei('0.01','ether'),
          gasLimit: DEFAULT_GAS_LIMIT,
      });

调用核心代码就这些,完成了一个nft测试网mint的调用。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值