Royalties
How should royalties be managed?
pub resource NFT: NonFungibleToken.INFT, MetadataViews.Resolver {
// ...
pub fun resolveView(_ view: Type): AnyStruct? {
switch view {
case Type<MetadataViews.Royalties>():
// note: Royalties are not aware of the token being used with, so the path is not useful right now
// eventually the FungibleTokenSwitchboard might be an option
// https://github.com/onflow/flow-ft/blob/master/contracts/FungibleTokenSwitchboard.cdc
let cut = MetadataViews.Royalty(
receiver: Avataaars.account.getCapability<&{FungibleToken.Receiver}>(/public/somePath),
cut: 0.025, // 2.5% royalty
description: "Creator Royalty"
)
var royalties: [MetadataViews.Royalty] = [cut]
return MetadataViews.Royalties(royalties)
// ...
}
return nil
}
// ...
}Last updated