DeploySEALED
╱□●%▫╲◇■█#╳▫●■░▫%#*~█╲●╲○█◆▓╲╲○~##▓*▪*□╱◇#●?◆╲!?▫$░*◇█□■●*▪$▓$&@
Transaction ID
Execution Fee
0.00000624 FLOWTransaction Summary
DeployContract deployment
Contract deployment
Script Arguments
0nameString
CampaignEscrow
1codeString
/**
* CampaignEscrow Contract
*
* Manages campaign escrow with USDF tokens and automated payouts
* Integrates with Flow Forte scheduled transactions for auto-refund
* Handles trustless campaign management between brands and creators
*/
import FungibleToken from 0xf233dcee88fe0abe
access(all) contract CampaignEscrow {
// Campaign data structure
access(all) struct Campaign {
access(all) let id: String
access(all) let creator: Address
access(all) let brand: Address
access(all) let threshold: UFix64
access(all) let payout: UFix64
access(all) let deadline: UFix64
access(all) let createdAt: UFix64
access(all) let scheduledTxId: String? // Forte scheduled transaction ID for auto-refund
init(
id: String,
creator: Address,
brand: Address,
threshold: UFix64,
payout: UFix64,
deadline: UFix64,
createdAt: UFix64,
scheduledTxId: String?
) {
self.id = id
self.creator = creator
self.brand = brand
self.threshold = threshold
self.payout = payout
self.deadline = deadline
self.createdAt = createdAt
self.scheduledTxId = scheduledTxId
}
}
// Oracle account for triggering payouts
access(all) let oracle: Address
// Storage for campaigns
access(all) var campaigns: {String: Campaign}
// Create a new campaign
access(all) fun createCampaign(
id: String,
creator: Address,
threshold: UFix64,
payout: UFix64,
deadline: UFix64
): Bool {
// Validate inputs
pre {
threshold > 0.0: "Threshold must be positive"
payout > 0.0: "Payout must be positive"
deadline > getCurrentBlock().timestamp: "Deadline must be in the future"
!self.campaigns.containsKey(id): "Campaign ID already exists"
}
// Create campaign
let campaign = Campaign(
id: id,
creator: creator,
brand: self.oracle, // Using oracle as brand for simplicity
threshold: threshold,
payout: payout,
deadline: deadline,
createdAt: getCurrentBlock().timestamp,
scheduledTxId: nil
)
// Store campaign
self.campaigns[id] = campaign
// Emit event
emit CampaignCreated(id: id, creator: creator, threshold: threshold, payout: payout)
return true
}
// Get campaign details
access(all) fun getCampaign(id: String): Campaign? {
return self.campaigns[id]
}
// Get all campaigns
access(all) fun getAllCampaigns(): [Campaign] {
let campaigns: [Campaign] = []
for campaign in self.campaigns.values {
campaigns.append(campaign)
}
return campaigns
}
// Events
access(all) event CampaignCreated(id: String, creator: Address, threshold: UFix64, payout: UFix64)
access(all) event PayoutTriggered(id: String, recipient: String, amount: UFix64)
access(all) event CampaignRefunded(id: String, brand: String, amount: UFix64)
init(oracleAddress: Address) {
self.oracle = oracleAddress
self.campaigns = {}
log("CampaignEscrow contract deployed with oracle: ".concat(self.oracle.toString()))
}
}
2arg0Address
Cadence Script
1transaction(name: String, code: String ,arg0:Address) {
2 prepare(signer: auth(AddContract) &Account) {
3 signer.contracts.add(name: name, code: code.utf8 ,arg0)
4 }
5 }