Smart Contract

CarClubTracker

A.66b60643244a7738.CarClubTracker

Deployed

16h ago
Feb 28, 2026, 02:29:07 AM UTC

Dependents

0 imports
1pub contract CarClubTracker {
2
3    pub struct PurchaseRecord {
4        pub let id: UInt64
5        pub let userAddress: Address
6        pub let itemType: String // "Single" or "Pack"
7        pub let rollout: String
8
9        init(_ id: UInt64, userAddress: Address, itemType: String, rollout: String) {
10            self.id = id
11            self.userAddress = userAddress
12            self.itemType = itemType
13            self.rollout = rollout
14        }
15    }
16
17    // Store for the purchase records
18    pub var purchaseRecords: {UInt64: PurchaseRecord}
19
20    // Global ID counter for purchase records
21    pub var nextId: UInt64
22
23    // Function to add a new purchase record
24    pub fun addPurchase(userAddress: Address, itemType: String, rollout: String) {
25        let newPurchase = PurchaseRecord(self.nextId, userAddress: userAddress, itemType: itemType, rollout: rollout)
26        self.purchaseRecords[self.nextId] = newPurchase
27        self.nextId = self.nextId + 1
28    }
29
30    init() {
31        self.purchaseRecords = {}
32        self.nextId = 0
33    }
34}