Collection Data

How do I store, send, or withdraw from this collection?

The NFTCollectionData view describes information critical to understanding how to talk to your collection. Without it, Flowty might not be able to ingest your collection or permit listings.

NFTCollectionData has a few key fields that Flowty relies on:

  1. storagePath: Where should this collection be saved if we are configuring an account's storage for this collection?

  2. publicPath: Where do we borrow public capabilities for this collection? This is primarily used for actions like transfers.

  3. providerPath: What is this collection's recommended path to withdraw items from? NOTE: This field is required to work with Hybrid Custody (Section coming soon)

  4. createEmptyCollection: A helper function that lets us initialize your collection from a metadata view. This function should return a resource that implements NonFungibleToken.Collection and be capable of storing your collection.

NOTE: While this metadata view does describe how to link your full collection type, Flowty will only set up standard interfaces on these paths. If you create an application that relies on other interfaces being linked, you will need to handle incomplete links and correct them, if detected.

pub contract Avataaars: NonFungibleToken, ViewResolver {
    // ...

    pub resource NFT: NonFungibleToken.INFT, MetadataViews.ResolverCollection {
        pub fun resolveView(_ view: Type): AnyStruct? {
            switch view {
                // ...
                case Type<MetadataViews.NFTCollectionData>():
                    return Avataaars.resolveView(view)
                // ...
            }
            return nil
        }
    }

    pub fun resolveView(_ view: Type): AnyStruct? {
        switch view {
            case Type<MetadataViews.NFTCollectionData>():
                return MetadataViews.NFTCollectionData(
                    storagePath: Avataaars.CollectionStoragePath,
                    publicPath: Avataaars.CollectionPublicPath,
                    providerPath: Avataaars.CollectionProviderPath,
                    publicCollection: Type<&Avataaars.Collection{Avataaars.AvataaarsCollectionPublic}>(),
                    publicLinkedType: Type<&Avataaars.Collection{Avataaars.AvataaarsCollectionPublic,NonFungibleToken.CollectionPublic,NonFungibleToken.Receiver,MetadataViews.ResolverCollection}>(),
                    providerLinkedType: Type<&Avataaars.Collection{Avataaars.AvataaarsCollectionPublic,NonFungibleToken.CollectionPublic,NonFungibleToken.Provider,MetadataViews.ResolverCollection}>(),
                    createEmptyCollectionFunction: (fun (): @NonFungibleToken.Collection {
                        return <-Avataaars.createEmptyCollection()
                    })
                )
            // ...
        }
        return nil
    }
}

Last updated