0

I am creating a contract with the diamond pattern so I can evolve and add new features to my contract.

Contract facets:

  1. Contract A: an ERC721 that takes care of minting its own NFTs
  2. Contract B: Business logic that takes user NFTs and mints new NFTs
  3. Contract C: Utility contract with essential function calls

I want to store the user's NFT and return it back to the user on returning the minted NFT. However, if I upgrade any contract, all NFTs held will be unusable by the new contract.

How should I implement such a vault account implementation?

1 Answer 1

0

When you upgrade one of your "facet"s, you are updating the code for that specific part of your "diamond"s functionality, this means that the logic may be different but the data remains inside of your diamond.

For example, if you update one part of your diamond, such as "Contract B", the minting mechanism will be altered, however, the data that tracks who owns which NFT will still exist inside your diamond wherever you decide to store that data.

Here is a diagram from the official ERC-2535 EIP:

enter image description here

Swapping out Facet B for a newer version won't affect the data stored inside DiamondStorage2.

2
  • Thanks for the answer! I get that data remains in diamond, I am concerned about NFTs/FTs held. If I am writing code to transferNFT(address(this)) in contract B, NFT goes to diamond contract or contract B? Commented Sep 26, 2023 at 11:45
  • @PiyushChittara the NFT "goes" to the diamond contract. contract B only contains some logic that is used by the diamond. The diamond contract delegateCalls your facets, which means that address(this) inside your facet is actually referring to your diamond contract.
    – Rohan Nero
    Commented Sep 26, 2023 at 14:54

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.