我正在创建一个从ERC1155继承的智能契约,但我得到了以下错误:
from solidity:
DeclarationError: Identifier not found or not unique.
--> contracts/Contract.sol:52:15:
|
52 | contract C is ERC1155, Ownable {
| ^^^^^^^尽管在一开始就导入了它(我也尝试用"@openzeppelin“导入它,但是没有工作。)
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/ERC1155.sol";我的合同代码几乎是空的,所以我不知道错误是从哪里来的:
contract C is ERC1155, Ownable {
using Strings for uint256;
string public nameContract;
uint256 public quantity;
uint256 public mintPrice;
constructor(
string memory _name,
string memory _icon,
uint256 _quantity,
uint256 _mintPrice
) public ERC1155()
{
}
// Implement functions to use on this contract
}另外,我还有另一个问题,假设我想创建一个n个不同项的集合,其中每个项目的数量x对集合中的每个项都不是相同的。例如,我收集的4个项目,数量为100,50,20和1。有办法做到这一点吗?ERC1155对此有用吗?还是我应该继续使用ERC721?
谢谢
发布于 2022-03-16 16:36:29
问题在于您的ERC1155(),因为ERC1155构造函数需要uri_
constructor(string memory uri_) {
_setURI(uri_);
}并且您正在使用空参数调用ERC1155()构造函数,尝试以下操作,它应该可以工作:
constructor(
string memory _name,
string memory _icon,
uint256 _quantity,
uint256 _mintPrice
) public ERC1155("your URI here")https://ethereum.stackexchange.com/questions/123984
复制相似问题