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?

Nerrosa
  • 1
  • 1

1 Answers1

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

Casareafer
  • 648
  • 2
  • 12
  • Thanks - so basically you are saying my code was correct? – Nerrosa Jul 17 '22 at 01: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 Jul 18 '22 at 02: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 Jul 18 '22 at 02:51
  • I also tested other data beyond the 6 in https://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 Jul 18 '22 at 02:54
  • you should be able to use any of these fields: https://docs.opensea.io/reference/collection-model I will test later :) – Casareafer Jul 19 '22 at 03:28
  • Yes, please test :-)

    I know for sure these work: name description, image, external_link, seller_fee_basis_points, fee_recipient which are taken directly from https://docs.opensea.io/docs/contract-level-metadata

    Interesting image works but image_url is the suggested field name through the link (https://docs.opensea.io/reference/collection-model) you found.

    Likewise with seller_fee_basis_points works but dev_seller_fee_basis_points is the suggested field name.

    And too, fee_recipient works but payout_address is the suggested field name.

    – Nerrosa Jul 19 '22 at 15:10