小编Krz*_*ztf的帖子

以太坊 - 资金不足以支付内在交易成本

我正在尝试创建自己的 NFT 合约工厂,但在主网上失败了。我的钱包里有 ETH。在测试中它工作正常。这是我的合同:

//Contract based on [https://docs.openzeppelin.com/contracts/3.x/erc721](https://docs.openzeppelin.com/contracts/3.x/erc721)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
contract NFT is ERC721URIStorage, Ownable {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    constructor() ERC721("NFT", "NFT") {}

    function mintNFT(address recipient, string memory tokenURI)
        public onlyOwner
        returns (uint256)
    {
        _tokenIds.increment();

        uint256 newItemId = _tokenIds.current();
        _mint(recipient, newItemId);
        _setTokenURI(newItemId, tokenURI);

        return newItemId;
    }
}

Run Code Online (Sandbox Code Playgroud)

这是我的合约部署脚本

   const MyNFT = await ethers.getContractFactory("NFT");
  const gasPrice = await MyNFT.signer.getGasPrice();
  const estimatedGas2 = await ethers.provider.estimateGas(MyNFT.getDeployTransaction().data)
  const …
Run Code Online (Sandbox Code Playgroud)

javascript ethereum smartcontracts hardhat

1
推荐指数
1
解决办法
4134
查看次数

标签 统计

ethereum ×1

hardhat ×1

javascript ×1

smartcontracts ×1