github.com/DapperCollectives/CAST/backend@v0.0.0-20230921221157-1350c8be7c96/main/cadence/nba/transactions/admin/create_play.cdc (about) 1 import TopShot from 0xf8d6e0586b0a20c7 2 3 // This transaction creates a new play struct 4 // and stores it in the Top Shot smart contract 5 // We currently stringify the metadata and insert it into the 6 // transaction string, but want to use transaction arguments soon 7 8 // Parameters: 9 // 10 // metadata: A dictionary of all the play metadata associated 11 12 transaction(metadata: {String: String}) { 13 14 // Local variable for the topshot Admin object 15 let adminRef: &TopShot.Admin 16 let currPlayID: UInt32 17 18 prepare(acct: AuthAccount) { 19 20 // borrow a reference to the admin resource 21 self.currPlayID = TopShot.nextPlayID; 22 self.adminRef = acct.borrow<&TopShot.Admin>(from: /storage/TopShotAdmin) 23 ?? panic("No admin resource in storage") 24 } 25 26 execute { 27 28 // Create a play with the specified metadata 29 self.adminRef.createPlay(metadata: metadata) 30 } 31 32 post { 33 34 TopShot.getPlayMetaData(playID: self.currPlayID) != nil: 35 "playID doesnt exist" 36 } 37 }