github.com/DapperCollectives/CAST/backend@v0.0.0-20230921221157-1350c8be7c96/main/cadence/transactions/setup_account_nfts.cdc (about) 1 import NonFungibleToken from 0xf8d6e0586b0a20c7 2 import ExampleNFT from 0xf8d6e0586b0a20c7 3 import MetadataViews from 0xf8d6e0586b0a20c7 4 5 /// This transaction is what an account would run 6 /// to set itself up to receive NFTs 7 transaction { 8 9 prepare(signer: AuthAccount) { 10 // Return early if the account already has a collection 11 if signer.borrow<&ExampleNFT.Collection>(from: ExampleNFT.CollectionStoragePath) != nil { 12 return 13 } 14 15 // Create a new empty collection 16 let collection <- ExampleNFT.createEmptyCollection() 17 18 // save it to the account 19 signer.save(<-collection, to: ExampleNFT.CollectionStoragePath) 20 21 // create a public capability for the collection 22 signer.link<&{NonFungibleToken.CollectionPublic, ExampleNFT.ExampleNFTCollectionPublic, MetadataViews.ResolverCollection}>( 23 ExampleNFT.CollectionPublicPath, 24 target: ExampleNFT.CollectionStoragePath 25 ) 26 } 27 }