使用 truffle 迁移带有继承的合同时出错
error migrating contract with inheritance using truffle
我在尝试迁移具有继承的合同时遇到此错误
错误:“NFTCollectible”--“未定义”的参数数量无效。得到 0 预期 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);
};
这是页面上的 NFTCollectible 合约:
所以这个合约有一个构造函数方法,它需要 1 个参数。所以当你部署合约时,你必须将参数传递给合约,如下所示:
var NFTCollectible = artifacts.require("NFTCollectible");
module.exports = function(deployer) {
// you have to pass the baseURI
deployer.deploy(NFTCollectible,"https://baseUriHere");
};
我在尝试迁移具有继承的合同时遇到此错误
错误:“NFTCollectible”--“未定义”的参数数量无效。得到 0 预期 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);
};
这是页面上的 NFTCollectible 合约:
所以这个合约有一个构造函数方法,它需要 1 个参数。所以当你部署合约时,你必须将参数传递给合约,如下所示:
var NFTCollectible = artifacts.require("NFTCollectible");
module.exports = function(deployer) {
// you have to pass the baseURI
deployer.deploy(NFTCollectible,"https://baseUriHere");
};