github.com/DapperCollectives/CAST/backend@v0.0.0-20230921221157-1350c8be7c96/main/cadence/transactions/setup_account_to_receive_royalty.cdc (about) 1 2 /// This transaction is a template for a transaction 3 /// to create a new link in their account to be used for receiving royalties 4 /// This transaction can be used for any fungible token, which is specified by the `vaultPath` argument 5 /// 6 /// If the account wants to receive royalties in FLOW, they'll use `/storage/flowTokenVault` 7 /// If they want to receive it in USDC, they would use FiatToken.VaultStoragePath 8 /// and so on. 9 /// The path used for the public link is a new path that in the future, is expected to receive 10 /// and generic token, which could be forwarded to the appropriate vault 11 12 import FungibleToken from 0xee82856bf20e2aa6 13 import MetadataViews from 0xf8d6e0586b0a20c7 14 15 transaction() { 16 17 prepare(signer: AuthAccount) { 18 19 // Return early if the account doesn't have a FungibleToken Vault 20 if signer.borrow<&FungibleToken.Vault>(from: /storage/flowTokenVault) == nil { 21 panic("A vault for the specified fungible token path does not exist") 22 } 23 24 // Create a public capability to the Vault that only exposes 25 // the deposit function through the Receiver interface 26 let capability = signer.link<&{FungibleToken.Receiver, FungibleToken.Balance}>( 27 MetadataViews.getRoyaltyReceiverPublicPath(), 28 target: /storage/flowTokenVault 29 )! 30 31 // Make sure the capability is valid 32 if !capability.check() { panic("Beneficiary capability is not valid!") } 33 } 34 }