首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ERC1155未正确导入

ERC1155未正确导入
EN

Ethereum用户
提问于 2022-03-16 15:21:23
回答 1查看 83关注 0票数 0

我正在创建一个从ERC1155继承的智能契约,但我得到了以下错误:

代码语言:javascript
复制
from solidity:
DeclarationError: Identifier not found or not unique.
  --> contracts/Contract.sol:52:15:
   |
52 | contract C is ERC1155, Ownable {
   |               ^^^^^^^

尽管在一开始就导入了它(我也尝试用"@openzeppelin“导入它,但是没有工作。)

代码语言:javascript
复制
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/ERC1155.sol";

我的合同代码几乎是空的,所以我不知道错误是从哪里来的:

代码语言:javascript
复制
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?

谢谢

EN

回答 1

Ethereum用户

发布于 2022-03-16 16:36:29

问题在于您的ERC1155(),因为ERC1155构造函数需要uri_

代码语言:javascript
复制
constructor(string memory uri_) {
    _setURI(uri_);
}

并且您正在使用空参数调用ERC1155()构造函数,尝试以下操作,它应该可以工作:

代码语言:javascript
复制
  constructor(
        string memory _name,
        string memory _icon,
        uint256 _quantity,
        uint256 _mintPrice
        ) public ERC1155("your URI here")
票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/123984

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档