0

I am trying to implement contract level metadata so "description", "image", external_link": etc show up on marketplaces, particularly OpenSea.

I have done an extensive search of the forums and nothing has addressed this already, so hoping this thread will shed some light.

I have added the following lines in Remix:

string _contractURI = "https://MY-CONTRACTURI-METADATA.com

function contractURI() public view returns (string memory) {

return _contractURI;

}

This actually successfully allows contract level metadata to shows up on OpenSea!

However, OpenSea doesn’t refresh from the JSON URI after the first time – it seems to be set once and cannot be changed.

Is this correct?

OpenSea documentation and forums do not offer any advice.

Next, the code compiles and deploys correctly to testnets, but it doesn’t load the ABI interface for read and write contract like the example code given in Contracts Wizard etc.

If I remove that string and function and recompile and redeploy the contract to testnets, the ABI interface for read and write contract LOADS.

What am I doing incorrectly here?

1 Answer 1

1

I struggled so much to find how to make this work but at the end was so simple.

create a .json file with the metadata and serve it with a simple http server

ie. if your file name is metadata.json your code should look something like this

string _contractURI = "https://yourDomain.com/metadata.json"

function contractURI() public view returns (string memory) {

return _contractURI;

}

OpenSea Documentation explicitly says URL https://docs.opensea.io/docs/contract-level-metadata

Edit: I tested this solution in an ERC1155 :D I suppose is the same for ERC721

6
  • Thanks - so basically you are saying my code was correct?
    – Nerrosa
    Commented Jul 17, 2022 at 1:38
  • From my perspective, your code is correct (you missed one --> ") but the endpoint should point either to an api that returns a .json or the .json itself (like my example) I used a basic http-server instance and expose it with a basic routing in my house modem to serve the metadata.json other thing that I seen, Opensea applies the metadata only when you deploy, it means that after deployment, if you decide to update the contract level metadata opensea will not refresh the collection.. <-- this behavior is at the time of writing
    – Casareafer
    Commented Jul 18, 2022 at 2:19
  • Thank you, again. Do you know why OpenSea doesn't refresh contract level metadata (i.e, need to get it correct first time) vs allow refresh of token metadata?
    – Nerrosa
    Commented Jul 18, 2022 at 2:51
  • I also tested other data beyond the 6 in docs.opensea.io/docs/contract-level-metadata and OpenSea doen't accept any, only those 6 - such as "banner_image_url". Do you know what other data can be in contract level metadata? And how does one submit a banner image URL to OpenSea after deployment?
    – Nerrosa
    Commented Jul 18, 2022 at 2:54
  • you should be able to use any of these fields: docs.opensea.io/reference/collection-model I will test later :)
    – Casareafer
    Commented Jul 19, 2022 at 3:28

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.