Smart Contract

FLOATVerifiers

A.a02c28dc0aa50c18.FLOATVerifiers

Deployed

2h ago
Feb 28, 2026, 09:42:43 PM UTC

Dependents

0 imports
1// MADE BY: Emerald City, Jacob Tucker
2
3// This contract is probably the most confusing element of the FLOAT
4// platform. Listed here is a bunch of Structs which all implement
5// FLOAT.IVerifier.
6
7// This pattern allows us to define arbitrary "restrictions" or "verifiers"
8// on our FLOAT Events. For example, Timelock is a verifier that makes sure
9// the current time is within the start and end date that the FLOAT Event host
10// specified when they created an event.
11
12// The cool part is all of these verifiers are totally optional, and are only
13// passed in with the newly created event if the host wanted to enable them.
14// You can mix and match them however you want. For example, one event I could
15// use both Timelock and Limited, and for another event I could just use Secret.
16
17// Each verifier must have a `verify` function that takes in a generalized `params`
18// argument so we can pass user data through as well as info about the event itself.
19// This is important for Secret for example because we want to pass the users guess
20// of the secret code through. For Limited, we need to know the totalSupply of the event,
21// so we pass it through as well.
22
23import MusicPeaksMembershipToken from 0xa02c28dc0aa50c18
24
25pub contract FLOATVerifiers {
26
27    // The "verifiers" to be used
28
29    //
30    // Timelock
31    //
32    // Specifies a time range in which the
33    // FLOAT from an event can be claimed
34    pub struct Timelock: MusicPeaksMembershipToken.IVerifier {
35        // An automatic switch handled by the contract
36        // to stop people from claiming after a certain time.
37        pub let dateStart: UFix64
38        pub let dateEnding: UFix64
39
40        pub fun verify(_ params: {String: AnyStruct}) {
41            assert(
42                getCurrentBlock().timestamp >= self.dateStart,
43                message: "This FLOAT Event has not started yet."
44            )
45            assert(
46                getCurrentBlock().timestamp <= self.dateEnding,
47                message: "Sorry! The time has run out to mint this FLOAT."
48            )
49        }
50
51        init(_dateStart: UFix64, _timePeriod: UFix64) {
52            self.dateStart = _dateStart
53            self.dateEnding = self.dateStart + _timePeriod
54        }
55    }
56
57    //
58    // Secret
59    //
60    // Specifies a secret code in order
61    // to claim a FLOAT (not very secure, but cool feature)
62    pub struct Secret: MusicPeaksMembershipToken.IVerifier {
63        // The secret code, set by the owner of this event.
64        access(self) let secretPhrase: String
65
66        pub fun verify(_ params: {String: AnyStruct}) {
67            let secretPhrase = params["secretPhrase"]! as! String
68            assert(
69                self.secretPhrase == secretPhrase,
70                message: "You did not input the correct secret phrase."
71            )
72        }
73
74        init(_secretPhrase: String) {
75            self.secretPhrase = _secretPhrase
76        }
77    }
78
79    //
80    // Limited
81    //
82    // Specifies a limit for the amount of people
83    // who can CLAIM. Not to be confused with how many currently
84    // hold a FLOAT from this event, since users can
85    // delete their FLOATs.
86    pub struct Limited: MusicPeaksMembershipToken.IVerifier {
87        pub var capacity: UInt64
88
89        pub fun verify(_ params: {String: AnyStruct}) {
90            let event = params["event"]! as! &MusicPeaksMembershipToken.FLOATEvent{MusicPeaksMembershipToken.FLOATEventPublic}
91            let currentCapacity = event.totalSupply
92            assert(
93                currentCapacity < self.capacity,
94                message: "This FLOAT Event is at capacity."
95            )
96        }
97
98        init(_capacity: UInt64) {
99            self.capacity = _capacity
100        }
101    }
102
103    //
104    // MultipleSecret
105    //
106    // Allows for Multiple Secret codes
107    // Everytime a secret gets used, it gets removed
108    // from the list.
109    pub struct MultipleSecret: MusicPeaksMembershipToken.IVerifier {
110        access(self) let secrets: {String: Bool}
111
112        pub fun verify(_ params: {String: AnyStruct}) {
113            let secretPhrase = params["secretPhrase"]! as! String
114            assert(
115                self.secrets[secretPhrase] != nil,
116                message: "You did not input a correct secret phrase."
117            )
118            self.secrets.remove(key: secretPhrase)
119        }
120
121        init(_secrets: [String]) {
122            self.secrets = {}
123            for secret in _secrets {
124                self.secrets[secret] = true
125            }
126        }
127    }
128
129    //
130    // SecretV2
131    //
132    // Much more secure than Secret
133    pub struct SecretV2: MusicPeaksMembershipToken.IVerifier {
134        pub let publicKey: String
135
136        pub fun verify(_ params: {String: AnyStruct}) {
137            let data: [UInt8] = (params["claimee"]! as! Address).toString().utf8
138            let sig: [UInt8] = (params["secretSig"]! as! String).decodeHex()
139            let publicKey = PublicKey(publicKey: self.publicKey.decodeHex(), signatureAlgorithm: SignatureAlgorithm.ECDSA_P256)
140            let valid = publicKey.verify(signature: sig, signedData: data, domainSeparationTag: "FLOW-V0.0-user", hashAlgorithm: HashAlgorithm.SHA3_256)
141
142            assert(
143                valid,
144                message: "You did not input the correct secret phrase."
145            )
146        }
147
148        init(_publicKey: String) {
149            self.publicKey = _publicKey
150        }
151    }
152
153}
154