0

I have created an ERC1155 smart contract which works perfectly fine on opensea - it finds the uri and the contractURI well. However, when I add the NFT on testnet to metamask, while the NFT data is accurate, the collection data seems to not be fetched. It puts the NFT in an Untitled Collection tab.

Here is the smart contract function:

    function contractURI() public view returns (string memory) {
return theContractUri;
}

Here is how the contact URI is formatted:

    {   

"collection" :{

    "name": "Farmverse Farmers",
    "image": "ipfs://bafkreic57ucjp6yrfjg4jt7x2533vm4vismg5gxm4phy4wkhbqlzydfvde/"

},
"collectible" :{

    "name": "Farmverse Farmers",
    "image": "ipfs://bafkreic57ucjp6yrfjg4jt7x2533vm4vismg5gxm4phy4wkhbqlzydfvde/"

},
"contract" :{

    "name": "Farmverse Farmers",
    "image": "ipfs://bafkreic57ucjp6yrfjg4jt7x2533vm4vismg5gxm4phy4wkhbqlzydfvde/"

},
    "name": "Farmverse Farmers",
    "description": "“The Farmers” is an NFT collection that contains 5555 unique, computer-generated little characters.  Besides being collectibles these tokens are also your key to unlocking the wonders of Farmverse – a multiplayer play-to-earn online video game.",
    "image": "ipfs://bafkreic57ucjp6yrfjg4jt7x2533vm4vismg5gxm4phy4wkhbqlzydfvde/",
    "external_link": "https://farm-verse.com"
}

So I do not understand, where is metamask trying to get the collection name from? Where shuld I put it in my contractURI or regular tokenURI in order for the collection name and image to show up in metamask mobile.

Thanks in advance!

1
  • were you able to figure this out? I ran into this same problem. May 15, 2022 at 18:09

1 Answer 1

1

i figured it out.

See what can be done, in the contract code:

string public name;
string public symbol;
event UpdateNameEvent(string oldName, string newName);
event UpdateSymbolEvent(string oldSymbol, string newSymbol);

constructor( string memory _name, string memory _symbol ) ERC1155('anything can be done here'){
    name = _name;
    symbol = _symbol;
}

and if you want to update later, you can have code to do that.

function updateName(string memory newName) external onlyOwner{
    string memory oldName = name;
    name = newName;
    emit UpdateNameEvent(oldName, name);
}

function updateSymbol(string memory newSymbol) external onlyOwner{
    string memory oldSymbol = symbol;
    symbol = newSymbol;
    emit UpdateSymbolEvent(oldSymbol, symbol);
}

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.