0

I am creating a smart contract that inheritate from ERC1155 but I get the following error:

from solidity:
DeclarationError: Identifier not found or not unique.
  --> contracts/Contract.sol:52:15:
   |
52 | contract C is ERC1155, Ownable {
   |               ^^^^^^^

Despite importing it at the beginning (I've tried to import it with "@openzeppelin" as well but did not work.

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/ERC1155.sol";

My code for the contract is pretty much empty so I'm not sure where is the error coming from:

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
}

Also I have another question, let's say I want to create a collection of n different items with each having a quantity x that is not the same for every item in the collection. For instance 4 items in my collection with a quantity of 100, 50, 20 and 1. Is there a way to do this? Is the ERC1155 useful for that or I should keep using the ERC721?

Thanks

2
  • I suggest you to open a new question for the second question
    – Adam Boudj
    Commented Mar 16, 2022 at 16:37
  • Hi, actually I found a way to do what I wanted for my second question ty though Commented Mar 16, 2022 at 18:51

1 Answer 1

0

the issue is on your ERC1155() as ERC1155 constructor needs uri_

constructor(string memory uri_) {
    _setURI(uri_);
}

and you're calling ERC1155() constructor with empty params try this instead and it should work:

  constructor(
        string memory _name,
        string memory _icon,
        uint256 _quantity,
        uint256 _mintPrice
        ) public ERC1155("your URI here")
3
  • Hi, adding the URI and setting up the function did not change anything. I'm still having the same error Commented Mar 16, 2022 at 18:54
  • this works perfectly on my remix, check again gist.github.com/Aboudjem/18b8f78496ef41fbed89aabc521ee6c8
    – Adam Boudj
    Commented Mar 16, 2022 at 22:07
  • Okay for some reason it seems like naming the contract C will result in an error. I changed the name to CR and it's working. Commented Mar 17, 2022 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.