Can I update the uri of ERC1155 contract after deployment?

Hi team,

I want to ask whether I could update uri of ERC1155 contract after deployment in case of the path of uri occurred change?

1 Like

Hi @llp0574,

Yes, you would need to add functionality to change the URI protected with appropriate access control so only accounts with permission could change the URI. (https://docs.openzeppelin.com/contracts/4.x/access-control#role-based-access-control)

You would also want to clearly communicate with your community under what circumstances this would be done.

One option would be to have this functionality controlled by a community multi-sig with various stakeholders in your community being signatories. Also see: https://blog.openzeppelin.com/admin-accounts-and-multisigs/

Thanks for your response! And I also want to ask should I emit the URI event when I change uri in a new functionality which may be called changeURI in my contract, is it a common way accepted by the third party NFT platform like Opensea?

1 Like

Hi @llp0574,

I checked the EIP (https://eips.ethereum.org/EIPS/eip-1155) and it has the following:

   /**
      @dev MUST emit when the URI is updated for a token ID.
       URIs are defined in RFC 3986.
       The URI MUST point to a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".
   */
   event URI(string _value, uint256 indexed _id);

Changes to the URI MUST emit the URI event if the change can be expressed with an event (i.e. it isn’t dynamic/programmatic).

I would check with any services that you are planning on using to see how they expect global changes to URI to be implemented.

Very kind of your response, and I’ve finished our contracts based on you suggestions, thank you very much!