CampaignInfo contract is the core campaign management contract in the Oak Network protocol. It stores campaign metadata, manages platform configurations, and controls campaign lifecycle states including launch time, deadline, and funding goals.
Overview
Key Features
- Campaign Metadata: Stores launch time, deadline, and goal amount
- Platform Management: Tracks selected and approved platforms for campaigns
- Fee Configuration: Manages protocol and platform fee percentages
- Access Control: Multiple levels of access (owner, platform admin, protocol admin)
- State Management: Pausable and cancellable with emergency controls
- Time Validation: Enforces launch and deadline constraints
State Variables
Campaign Data
| Variable | Type | Description |
|---|---|---|
s_campaignData | CampaignData | Campaign configuration (launch time, deadline, goal) |
s_identifierHash | bytes32 | Unique campaign identifier |
Platform Management
| Variable | Type | Description |
|---|---|---|
s_platformTreasuryAddress | mapping(bytes32 => address) | Maps platform hash to treasury address |
s_platformFeePercent | mapping(bytes32 => uint256) | Maps platform hash to fee percentage |
s_isSelectedPlatform | mapping(bytes32 => bool) | Whether platform is selected for campaign |
s_isApprovedPlatform | mapping(bytes32 => bool) | Whether platform is approved (treasury deployed) |
s_platformData | mapping(bytes32 => bytes32) | Platform-specific data storage |
s_approvedPlatformHashes | bytes32[] | Array of approved platform hashes |
Functions
Initialization
Constructor
creator: Address of the campaign creator (becomes owner)
- Sets the contract owner to the creator
- Initializes base contracts
Initialize
creator: Address of the campaign creatorglobalParams: Global parameters contract referenceselectedPlatformHash: Array of selected platform hashesplatformDataKey: Array of platform data keysplatformDataValue: Array of platform data valuescampaignData: Campaign configuration data
- Initializes the campaign with configuration data
- Sets up platform selections
- Configures platform-specific data
- Registers with global parameters
- Can only be called once (initializer modifier)
- Launch time must be in the future
- Deadline must be after launch time
- Goal amount must be greater than zero
- Platform arrays must have matching lengths
Campaign Data Retrieval
Get Campaign Config
- Complete campaign configuration including treasury factory, token, protocol fee, and identifier
Get Launch Time
- Campaign launch timestamp
Get Deadline
- Campaign end timestamp
Get Goal Amount
- Funding goal amount in campaign’s token
Get Token Address
- Address of the campaign’s token contract
Get Protocol Fee Percent
- Protocol fee percentage
Get Identifier Hash
- Unique campaign identifier hash
Platform Management
Check If Platform Selected
platformHash: Platform identifier hash
- True if platform is selected for the campaign
Check If Platform Approved
platformHash: Platform identifier hash
- True if platform has treasury deployed
Get Approved Platform Hashes
- Array of all approved platform hashes
Get Platform Admin Address
platformHash: Platform identifier hash
- Address of the platform administrator
Get Platform Fee Percent
platformHash: Platform identifier hash
- Platform fee percentage for the campaign
Get Platform Data
platformDataKey: Platform data key
- Platform-specific data value
Campaign Updates
Update Launch Time
launchTime: New launch timestamp
- Updates campaign launch time
- Emits
CampaignInfoLaunchTimeUpdatedevent
- Only callable by owner
- Campaign must not be launched yet
- Campaign must not be paused or cancelled
Update Deadline
deadline: New deadline timestamp
- Updates campaign deadline
- Emits
CampaignInfoDeadlineUpdatedevent
- Only callable by owner
- Campaign must not be launched yet
- Deadline must be after launch time
Update Goal Amount
goalAmount: New funding goal amount
- Updates campaign goal amount
- Emits
CampaignInfoGoalAmountUpdatedevent
- Only callable by owner
- Campaign must not be launched yet
- Goal amount must be greater than zero
Update Selected Platform
platformHash: Platform identifier hashselection: Whether to select the platform
- Updates platform selection status
- Emits
CampaignInfoSelectedPlatformUpdatedevent
- Only callable by owner
- Campaign must not be launched yet
- Platform must not be approved (treasury deployed)
Access Control
Owner
- Address of the campaign owner
Transfer Ownership
newOwner: New owner address
- Transfers campaign ownership
- Only callable by current owner
- Campaign must not be paused or cancelled
Get Protocol Admin Address
- Address of the protocol administrator
State Management
Paused
- True if campaign is paused
Cancelled
- True if campaign is cancelled
Pause Campaign
message: Reason for pausing
- Pauses the campaign
- Prevents all state-changing operations
- Only callable by protocol admin
Unpause Campaign
message: Reason for unpausing
- Resumes the campaign
- Re-enables state-changing operations
- Only callable by protocol admin
Cancel Campaign
message: Reason for cancellation
- Cancels the campaign
- Irreversibly ends the campaign
- Only callable by owner or protocol admin
Platform Information
Set Platform Info
platformHash: Platform identifier hashplatformTreasuryAddress: Platform treasury address
- Sets platform treasury address and fee configuration
- Marks platform as approved
- Emits
CampaignInfoPlatformInfoUpdatedevent
- Campaign must not be paused
Events
CampaignInfoLaunchTimeUpdated
CampaignInfoDeadlineUpdated
CampaignInfoGoalAmountUpdated
CampaignInfoSelectedPlatformUpdated
CampaignInfoPlatformInfoUpdated
Errors
CampaignInfoInvalidPlatformUpdate
CampaignInfoUnauthorized
CampaignInfoInvalidInput
CampaignInfoPlatformNotSelected
CampaignInfoPlatformAlreadyApproved
Data Structures
CampaignData
Config
Usage Examples
Reading Campaign Information
Updating Campaign Parameters
Platform Management
Security Considerations
Access Control
- Owner Only: Critical updates (launch time, deadline, goal) can only be made by owner
- Pre-Launch Only: Most updates can only be made before campaign launch
- Platform Protection: Approved platforms cannot be modified
- Emergency Controls: Protocol admin can pause/cancel campaigns
Time Validation
- Launch Time: Must be in the future when set
- Deadline: Must be after launch time
- Launch Lock: Once launched, timeline cannot be modified
- Time Checkers: All time updates use
TimestampCheckervalidations
State Protection
- Paused State: Prevents most state changes
- Cancelled State: Campaign operations are permanently disabled
- Irreversible: Cancellation is permanent
Gas Optimization
Storage Layout
The contract uses efficient storage patterns:- Packed storage for mappings
- Minimal state variables
- Efficient array operations
Access Patterns
- Read-only operations are gas-free (view functions)
- State updates only when necessary
- Batch operations minimize calls
Integration Notes
With CampaignInfoFactory
With Treasury
Next Steps
- CampaignInfoFactory - Factory contract documentation
- GlobalParams - Global parameters contract
- TreasuryFactory - Treasury creation contract
- Platform Integration - How to integrate platforms