github.com/DapperCollectives/CAST/backend@v0.0.0-20230921221157-1350c8be7c96/main/cadence/transactions/create_collection.cdc (about)

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