简体   繁体   中英

error migrating contract with inheritance using truffle

I get this error when trying to migrate a contract with an inheritance

Error: "NFTCollectible" -- Invalid number of parameters for "undefined". Got 0 expected 1..

/contracts/NFTCollectible.sol

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";

contract NFTCollectible is ERC721Enumerable, Ownable {
        using SafeMath for uint256;
        using Counters for Counters.Counter;
        ...    
    }

/migrations/2_deploy_contracts.js

var NFTCollectible = artifacts.require("NFTCollectible");

module.exports = function(deployer) {
    deployer.deploy(NFTCollectible);
};

this is the NFTCollectible contract on the page:

在此处输入图像描述

so this contract has a constructor method and it requires 1 argument. so when you deploy the contract, you have to pass the parameter to the conract as below:

var NFTCollectible = artifacts.require("NFTCollectible");

module.exports = function(deployer) {
    // you have to pass the baseURI
    deployer.deploy(NFTCollectible,"https://baseUriHere");
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM