0

I'm trying to create an ERC1155 NFT but when I deploy the contract and try to see it on Opensea testnet, it always show "Unidentified contract" whereas I didn't have any problem with ERC721.

Here is the difference : When you create an ERC721 you can add the name of the ERC721 token with its symbol like this :

contract MyNFT is ERC721URIStorage {
  using Counters for Counters.Counter;
  Counters.Counter private _tokenIds;

  constructor() ERC721 ("NAME", "SYMBOL") {
  }

However, this is completely different for ERC1155 tokens, this is my code :

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyNFT is ERC1155, Ownable {
    constructor() ERC1155("JSON FILE WITH METADATA") {
        _mint(msg.sender,1,1,"");
    }

And this is what I have on my json file metadatas

{
   "name":"Sword",
   "description":"Sword from GameItems",
   "image":"link_picture"
}

By looking at this https://eips.ethereum.org/EIPS/eip-1155#rationale It seems that in order to put a name for the collection I have to insert it on the metadata itself, but I don't know which designation I have to use. I tried this:

{
   "title":"GameItems",
   "name":"Sword",
   "description":"Sword from GameItems",
   "image":"link_picture"
}

But it's not working. Did anyone succed in applying a name for the collection on Opensea ? It would be very helpful to have some advice

Thanks

1 Answer 1

2

If you just want to add a name and a symbol you can do the following:

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyNFT is ERC1155, Ownable {
    
    string public name;
    string public symbol;
    
    constructor() ERC1155("JSON FILE WITH METADATA") {
        name = "Hello World 4321";
        symbol = "HELO";
        _mint(msg.sender,1,1,"");
    }
}

However if you want to define even more details about your collection and you only care about what people see on OpenSea. You could do something like this:

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyNFT is ERC1155, Ownable {
    
    constructor() ERC1155("JSON FILE WITH METADATA") {
        _mint(msg.sender,1,1,"");
    }
    
    function contractURI() public view returns (string memory) {
        return "https://LINK-TO-COLLECTION-METADATA";
    }
}

And then upload another metadata file. NOTE this metadata file is not about the NFT its a seperate file about the collection.

{
  "name": "Hello World 4321",
  "description": "Welcome to my collection about Hello World 4321",
  "image": "https://link-to-image",
  "external_link": "https://link-to-website",
  "seller_fee_basis_points": 100, # Indicates a 1% seller fee.
  "fee_recipient": "YOUR_ADDRESS_TO_COLLECT_ROYALTIES" 
}

I got this from here. You can also combine the code from both examples and do both :) Hope this helps!

P.S you didn't ask about it so maybe you have it covered. But I just want you to know that you might have an issue visualising your NFTs on OpenSea if you dont override the uri() function. Like in this example I created for EatTheBlocks.

1
  • How to set them already for sale? Or, how to set the floor price for the collection?
    – Dr.jacky
    Dec 29, 2021 at 20:10

Your Answer

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

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