Smart Contract

CreatorProfileV2

A.14aca78d100d2001.CreatorProfileV2

Valid From

130,652,340

Deployed

6d ago
Feb 21, 2026, 03:02:22 PM UTC

Dependents

13 imports
1access(all) contract CreatorProfileV2 {
2
3    access(all) let oracle: Address
4
5    access(all) resource Proof {
6        access(all) let postId: String
7        access(all) let score: UFix64
8        access(all) let timestamp: UFix64
9        access(all) let campaignId: String
10
11        init(postId: String, score: UFix64, timestamp: UFix64, campaignId: String) {
12            self.postId = postId
13            self.score = score
14            self.timestamp = timestamp
15            self.campaignId = campaignId
16        }
17    }
18
19    // Public interface you expose via a capability
20    access(all) resource interface ProfilePublic {
21        access(all) fun addProof(proof: @Proof)
22    }
23
24    access(all) resource Profile: ProfilePublic {
25        access(all) var proofs: @[Proof]
26
27        init() {
28            self.proofs <- [] as @[Proof]
29        }
30
31        access(all) fun addProof(proof: @Proof) {
32            self.proofs.append(<-proof)
33        }
34    }
35
36    access(all) fun createEmptyProfile(): @CreatorProfileV2.Profile {
37        return <- create CreatorProfileV2.Profile()
38    }
39
40    access(all) fun createProof(postId: String, score: UFix64, timestamp: UFix64, campaignId: String): @Proof {
41        return <- create Proof(postId: postId, score: score, timestamp: timestamp, campaignId: campaignId)
42    }
43
44    // Contract-level wrapper with oracle check
45    access(all) fun addProofFor(
46        creator: Address,
47        postId: String,
48        score: UFix64,
49        timestamp: UFix64,
50        campaignId: String,
51        signer: Address
52    ) {
53        pre { signer == self.oracle: "only oracle may add proof" }
54
55        let creatorAcct = getAccount(creator)
56        let cap: Capability<&{CreatorProfileV2.ProfilePublic}> = creatorAcct.capabilities.get<&{CreatorProfileV2.ProfilePublic}>(/public/CreatorProfile)!
57
58        let profileRef = cap.borrow()
59            ?? panic("Creator profile not found or wrong cap type")
60
61        let proof <- self.createProof(
62            postId: postId,
63            score: score,
64            timestamp: timestamp,
65            campaignId: campaignId
66        )
67
68        profileRef.addProof(proof: <-proof)
69    }
70
71    init(oracle: Address) {
72        self.oracle = oracle
73    }
74}