github.com/DapperCollectives/CAST/backend@v0.0.0-20230921221157-1350c8be7c96/main/cadence/nba/transactions/admin/mint_moment.cdc (about) 1 import TopShot from 0xf8d6e0586b0a20c7 2 3 // This transaction is what an admin would use to mint a single new moment 4 // and deposit it in a user's collection 5 6 // Parameters: 7 // 8 // setID: the ID of a set containing the target play 9 // playID: the ID of a play from which a new moment is minted 10 // recipientAddr: the Flow address of the account receiving the newly minted moment 11 12 transaction(setID: UInt32, playID: UInt32, recipientAddr: Address) { 13 // local variable for the admin reference 14 let adminRef: &TopShot.Admin 15 16 prepare(acct: AuthAccount) { 17 // borrow a reference to the Admin resource in storage 18 self.adminRef = acct.borrow<&TopShot.Admin>(from: /storage/TopShotAdmin)! 19 } 20 21 execute { 22 // Borrow a reference to the specified set 23 let setRef = self.adminRef.borrowSet(setID: setID) 24 25 // Mint a new NFT 26 let moment1 <- setRef.mintMoment(playID: playID) 27 28 // get the public account object for the recipient 29 let recipient = getAccount(recipientAddr) 30 31 // get the Collection reference for the receiver 32 let receiverRef = recipient.getCapability(/public/MomentCollection).borrow<&{TopShot.MomentCollectionPublic}>() 33 ?? panic("Cannot borrow a reference to the recipient's moment collection") 34 35 // deposit the NFT in the receivers collection 36 receiverRef.deposit(token: <-moment1) 37 } 38 }