Skip to content

Instantly share code, notes, and snippets.

@harry830622
Created February 27, 2022 06:26
Show Gist options
  • Save harry830622/578fbb6d744fa4522d160fe959639449 to your computer and use it in GitHub Desktop.
Save harry830622/578fbb6d744fa4522d160fe959639449 to your computer and use it in GitHub Desktop.
// 初始化合約,
// 創造一個全新 collection 作為官方 reserve ,
// 然後也創造一個 Admin 來管裡所有 NBA Top Shot 卡片的狀態,
// 並發出合約已經初始化的 event
init() {
// Initialize contract fields
self.currentSeries = 0
self.playDatas = {}
self.setDatas = {}
self.sets <- {}
self.nextPlayID = 1
self.nextSetID = 1
self.totalSupply = 0
// Put a new Collection in storage
self.account.save<@Collection>(<- create Collection(), to: /storage/MomentCollection)
// Create a public capability for the Collection
self.account.link<&{MomentCollectionPublic}>(/public/MomentCollection, target: /storage/MomentCollection)
// Put the Minter in storage
self.account.save<@Admin>(<- create Admin(), to: /storage/TopShotAdmin)
emit ContractInitialized()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment