Skip to content

Instantly share code, notes, and snippets.

@harry830622
Last active February 27, 2022 06:29
Show Gist options
  • Save harry830622/c1b9355811b4a7c1ee74526a6a807a16 to your computer and use it in GitHub Desktop.
Save harry830622/c1b9355811b4a7c1ee74526a6a807a16 to your computer and use it in GitHub Desktop.
transaction {
prepare(acct: AuthAccount) {
// First, check to see if a moment collection already exists
if acct.borrow<&TopShot.Collection>(from: /storage/MomentCollection) == nil {
// create a new TopShot Collection
let collection <- TopShot.createEmptyCollection() as! @TopShot.Collection
// Put the new Collection in storage
acct.save(<-collection, to: /storage/MomentCollection)
// create a public capability for the collection
acct.link<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection, target: /storage/MomentCollection)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment