forked from geniesinc/flow-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
great-token.cdc
56 lines (47 loc) · 1.09 KB
/
great-token.cdc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
pub contract GreatToken {
pub resource interface NFT {
pub fun id(): Int {
post {
result > 0
}
}
}
pub resource GreatNFT: NFT {
priv let _id: Int
priv let _special: Bool
pub fun id(): Int {
return self._id
}
pub fun isSpecial(): Bool {
return self._special
}
init(id: Int, isSpecial: Bool) {
pre {
id > 0
}
self._id = id
self._special = isSpecial
}
}
pub resource GreatNFTMinter {
pub var nextID: Int
pub let specialMod: Int
pub fun mint(): @GreatNFT {
var isSpecial = self.nextID % self.specialMod == 0
let nft <- create GreatNFT(id: self.nextID, isSpecial: isSpecial)
self.nextID = self.nextID + 1
return <-nft
}
init(firstID: Int, specialMod: Int) {
pre {
firstID > 0
specialMod > 1
}
self.nextID = firstID
self.specialMod = specialMod
}
}
pub fun createGreatNFTMinter(firstID: Int, specialMod: Int): @GreatNFTMinter {
return <-create GreatNFTMinter(firstID: firstID, specialMod: specialMod)
}
}