Collection Display
How should the collection this NFT belongs to be shown on Flowty?
Last updated
How should the collection this NFT belongs to be shown on Flowty?
Last updated
pub contract Avataaars: NonFungibleToken, ViewResolver {
// ...
pub resource NFT: NonFungibleToken.INFT, MetadataViews.ResolverCollection {
pub fun resolveView(_ view: Type): AnyStruct? {
switch view {
// ...
case Type<MetadataViews.NFTCollectionDisplay>():
return Avataaars.resolveView(view)
// ...
}
return nil
}
}
pub fun resolveView(_ view: Type): AnyStruct? {
switch view {
// ...
case Type<MetadataViews.NFTCollectionDisplay>():
return MetadataViews.NFTCollectionDisplay(
name: "Flowty Avataaars",
description: "This collection is used showcase the various things you can do with metadata standards on Flowty",
externalURL: MetadataViews.ExternalURL("https://flowty.io/"),
squareImage: MetadataViews.Media(
file: MetadataViews.HTTPFile(
url: self.imageBaseURL.concat("1")
),
mediaType: "image/jpeg"
),
bannerImage: MetadataViews.Media(
file: MetadataViews.HTTPFile(
url: "https://storage.googleapis.com/flowty-images/flowty-banner.jpeg"
),
mediaType: "image/jpeg"
),
socials: {
"twitter": MetadataViews.ExternalURL("https://twitter.com/flowty_io")
}
)
}
return nil
}
}
/// View to expose the information needed to showcase this NFT's
/// collection. This can be used by applications to give an overview and
/// graphics of the NFT collection this NFT belongs to.
///
pub struct NFTCollectionDisplay {
// Name that should be used when displaying this NFT collection.
pub let name: String
// Description that should be used to give an overview of this collection.
pub let description: String
// External link to a URL to view more information about this collection.
pub let externalURL: ExternalURL
// Square-sized image to represent this collection.
pub let squareImage: Media
// Banner-sized image for this collection, recommended to have a size near 1200x630.
pub let bannerImage: Media
// Social links to reach this collection's social homepages.
// Possible keys may be "instagram", "twitter", "discord", etc.
pub let socials: {String: ExternalURL}
// init truncated...
}