01 Apr 2022
Contributed by Flow Blockchain
This is how you use the metadata contract to actually access the views to show your metadata.
Smart Contract Example
The following functions are to be included in your NFT resource when creating a contract.
getViews tells someone all the views your NFT has, while resolveView returns the metadata from that view.
In your Collection resource you will have the borrowViewResolver function that is available in the Metadata Contract. You will need to import the MetadataViews.ResolverCollection interface into your collection.
This returns the capability for the NFT to use the above functions.
Here we borrow the capability to use the borrowViewResolver function.
When that is done, we then have the ability to use the functions resolveView and getViews if they are in our NFT resource.
After that we return the display.
Up Next: Multiple Metadata Views