Skip to main content
The 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

Platform Management

Functions

Initialization

Constructor

Parameters:
  • creator: Address of the campaign creator (becomes owner)
Effects:
  • Sets the contract owner to the creator
  • Initializes base contracts

Initialize

Parameters:
  • creator: Address of the campaign creator
  • globalParams: Global parameters contract reference
  • selectedPlatformHash: Array of selected platform hashes
  • platformDataKey: Array of platform data keys
  • platformDataValue: Array of platform data values
  • campaignData: Campaign configuration data
Effects:
  • Initializes the campaign with configuration data
  • Sets up platform selections
  • Configures platform-specific data
  • Registers with global parameters
Requirements:
  • 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

Returns:
  • Complete campaign configuration including treasury factory, token, protocol fee, and identifier

Get Launch Time

Returns:
  • Campaign launch timestamp

Get Deadline

Returns:
  • Campaign end timestamp

Get Goal Amount

Returns:
  • Funding goal amount in campaign’s token

Get Token Address

Returns:
  • Address of the campaign’s token contract

Get Protocol Fee Percent

Returns:
  • Protocol fee percentage

Get Identifier Hash

Returns:
  • Unique campaign identifier hash

Platform Management

Check If Platform Selected

Parameters:
  • platformHash: Platform identifier hash
Returns:
  • True if platform is selected for the campaign

Check If Platform Approved

Parameters:
  • platformHash: Platform identifier hash
Returns:
  • True if platform has treasury deployed

Get Approved Platform Hashes

Returns:
  • Array of all approved platform hashes

Get Platform Admin Address

Parameters:
  • platformHash: Platform identifier hash
Returns:
  • Address of the platform administrator

Get Platform Fee Percent

Parameters:
  • platformHash: Platform identifier hash
Returns:
  • Platform fee percentage for the campaign

Get Platform Data

Parameters:
  • platformDataKey: Platform data key
Returns:
  • Platform-specific data value

Campaign Updates

Update Launch Time

Parameters:
  • launchTime: New launch timestamp
Effects:
  • Updates campaign launch time
  • Emits CampaignInfoLaunchTimeUpdated event
Requirements:
  • Only callable by owner
  • Campaign must not be launched yet
  • Campaign must not be paused or cancelled

Update Deadline

Parameters:
  • deadline: New deadline timestamp
Effects:
  • Updates campaign deadline
  • Emits CampaignInfoDeadlineUpdated event
Requirements:
  • Only callable by owner
  • Campaign must not be launched yet
  • Deadline must be after launch time

Update Goal Amount

Parameters:
  • goalAmount: New funding goal amount
Effects:
  • Updates campaign goal amount
  • Emits CampaignInfoGoalAmountUpdated event
Requirements:
  • Only callable by owner
  • Campaign must not be launched yet
  • Goal amount must be greater than zero

Update Selected Platform

Parameters:
  • platformHash: Platform identifier hash
  • selection: Whether to select the platform
Effects:
  • Updates platform selection status
  • Emits CampaignInfoSelectedPlatformUpdated event
Requirements:
  • Only callable by owner
  • Campaign must not be launched yet
  • Platform must not be approved (treasury deployed)

Access Control

Owner

Returns:
  • Address of the campaign owner

Transfer Ownership

Parameters:
  • newOwner: New owner address
Effects:
  • Transfers campaign ownership
Requirements:
  • Only callable by current owner
  • Campaign must not be paused or cancelled

Get Protocol Admin Address

Returns:
  • Address of the protocol administrator

State Management

Paused

Returns:
  • True if campaign is paused

Cancelled

Returns:
  • True if campaign is cancelled

Pause Campaign

Parameters:
  • message: Reason for pausing
Effects:
  • Pauses the campaign
  • Prevents all state-changing operations
Requirements:
  • Only callable by protocol admin

Unpause Campaign

Parameters:
  • message: Reason for unpausing
Effects:
  • Resumes the campaign
  • Re-enables state-changing operations
Requirements:
  • Only callable by protocol admin

Cancel Campaign

Parameters:
  • message: Reason for cancellation
Effects:
  • Cancels the campaign
  • Irreversibly ends the campaign
Requirements:
  • Only callable by owner or protocol admin

Platform Information

Set Platform Info

Parameters:
  • platformHash: Platform identifier hash
  • platformTreasuryAddress: Platform treasury address
Effects:
  • Sets platform treasury address and fee configuration
  • Marks platform as approved
  • Emits CampaignInfoPlatformInfoUpdated event
Requirements:
  • Campaign must not be paused

Events

CampaignInfoLaunchTimeUpdated

Emitted when: Campaign launch time is updated

CampaignInfoDeadlineUpdated

Emitted when: Campaign deadline is updated

CampaignInfoGoalAmountUpdated

Emitted when: Campaign goal amount is updated

CampaignInfoSelectedPlatformUpdated

Emitted when: Platform selection status changes

CampaignInfoPlatformInfoUpdated

Emitted when: Platform treasury is deployed and configured

Errors

CampaignInfoInvalidPlatformUpdate

Emitted when: Attempting to update an already-approved platform

CampaignInfoUnauthorized

Emitted when: Unauthorized action attempted

CampaignInfoInvalidInput

Emitted when: Invalid input provided

CampaignInfoPlatformNotSelected

Emitted when: Platform operation attempted on non-selected platform

CampaignInfoPlatformAlreadyApproved

Emitted when: Platform is already approved

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 TimestampChecker validations

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