Smart Contract

ChainzAdmin

A.ff342b6df9ef019d.ChainzAdmin

Deployed

2h ago
Feb 28, 2026, 06:37:35 PM UTC

Dependents

0 imports
1import ChainzPack from 0xff342b6df9ef019d
2import ChainzNFT from 0xff342b6df9ef019d
3import ChainzKey from 0xff342b6df9ef019d
4
5pub contract ChainzAdmin {
6
7    pub let AdminStoragePath: StoragePath
8
9    pub resource Admin {
10
11        // openPack
12        // calls openPack on the user's Pack Collection
13        //
14        pub fun openPack(
15            id: UInt64, 
16            packCollectionRef: &ChainzPack.Collection{ChainzPack.AdminAccessible}, 
17            cardCollectionRef: &ChainzNFT.Collection{ChainzNFT.CollectionPublic}, 
18            names: [String], 
19            descriptions: [String], 
20            thumbnails: [String],
21            metadatas: [{String: String}],
22            keyTiers: [String],
23            keyTypes: [String],
24            keySerials: [UInt64],
25            keyMetadatas: [{String: String}]
26        ) {
27            packCollectionRef.openPack(id: id, cardCollectionRef: cardCollectionRef, names: names, descriptions: descriptions, thumbnails: thumbnails, metadatas: metadatas)
28
29            // Mint the user a Chainz Ket
30            let recipient = packCollectionRef.owner!.address
31            let chainzKeyCollection = getAccount(recipient).getCapability(ChainzKey.CollectionPublicPath)
32                                        .borrow<&ChainzKey.Collection{ChainzKey.CollectionPublic}>()
33                                        ?? panic("This user does not have a ChainzKey Collection set up.")
34            
35            var i: Int = 0
36            while i < keyTiers.length {
37                chainzKeyCollection.deposit(token: <- ChainzKey.createNFT(tier: keyTiers[i], type: keyTypes[i], serial: keySerials[i], metadata: keyMetadatas[i]))
38                i = i + 1
39            }
40        }
41     
42        pub fun airdropMoments(
43            cardCollectionRef: &ChainzNFT.Collection{ChainzNFT.CollectionPublic}, 
44            names: [String], 
45            descriptions: [String], 
46            thumbnails: [String],
47            metadatas: [{String: String}],
48        ) {
49            let recipient = cardCollectionRef.owner!.address
50            let chainzNFTCollection = getAccount(recipient).getCapability(ChainzNFT.CollectionPublicPath)
51                                        .borrow<&ChainzNFT.Collection{ChainzNFT.CollectionPublic}>()
52                                        ?? panic("This user does not have a ChainzNFT Collection set up.")
53
54            var i: Int = 0
55            while i < names.length {
56                chainzNFTCollection.deposit(token: <- ChainzNFT.createNFT(name: names[i], description: descriptions[i], thumbnail: thumbnails[i], metadata: metadatas[i]))
57                i = i + 1
58            }  
59
60        }
61
62        pub fun createPackType(name: String, price: UFix64, maxSupply: UInt64, reserved: UInt64, extra: {String: String}) {
63            ChainzPack.createPackType(name: name, price: price, maxSupply: maxSupply, reserved: reserved, extra: extra)
64        }
65
66         pub fun togglePackTypeActive(id: UInt64) {
67            ChainzPack.toggleActive(packTypeId: id)
68        }
69
70        pub fun reserveMintPack(packCollectionRef: &ChainzPack.Collection{ChainzPack.CollectionPublic}, packTypeId: UInt64) {
71            ChainzPack.reserveMint(packCollectionRef: packCollectionRef, packTypeId: packTypeId)
72        }
73
74        // createAdmin
75        // only an admin can ever create
76        // a new Admin resource
77        //
78        pub fun createAdmin(): @Admin {
79            return <- create Admin()
80        }
81
82        init() {
83            
84        }
85    }
86
87    init() {
88        self.AdminStoragePath = /storage/ChainzAdmin
89        self.account.save(<- create Admin(), to: self.AdminStoragePath)
90    }
91}
92