Interfaces Overview
Oak Network uses a comprehensive set of interfaces that define the contracts' external APIs. This section provides a reference for all interfaces in the protocol.
Available Interfaces
Core Protocol Interfaces
- ICampaignInfo - Campaign management interface
- ICampaignInfoFactory - Factory interface
- IGlobalParams - Protocol configuration interface
- ICampaignTreasury - Treasury operations interface
- ITreasuryFactory - Treasury factory interface
Reward and Item Interfaces
- IReward - Reward system interface
- IItem - Item management interface
- ICampaignData - Campaign data structures
ICampaignInfo
The main interface for campaign information and management.
Functions:
owner()- Get campaign ownergetLaunchTime()- Get launch timestampgetDeadline()- Get campaign deadlinegetGoalAmount()- Get funding goalgetTokenAddress()- Get campaign tokengetProtocolFeePercent()- Get protocol feecheckIfPlatformSelected()- Check platform selectiongetPlatformFeePercent()- Get platform feegetTotalRaisedAmount()- Get total raisedpaused()- Check if pausedcancelled()- Check if cancelled
ICampaignInfoFactory
Interface for the campaign factory contract.
Functions:
createCampaign()- Create new campaignupdateImplementation()- Update implementationisValidCampaignInfo()- Validate campaign
IGlobalParams
Interface for global protocol parameters.
Functions:
getProtocolAdminAddress()- Get protocol admingetTokenAddress()- Get default tokengetProtocolFeePercent()- Get protocol feecheckIfPlatformIsListed()- Check platform listinggetPlatformAdminAddress()- Get platform admingetPlatformFeePercent()- Get platform feegetNumberOfListedPlatforms()- Get platform count
ICampaignTreasury
Interface for treasury operations.
Functions:
getPlatformHash()- Get platform identifiergetPlatformFeePercent()- Get platform feedisburseFees()- Distribute feeswithdraw()- Withdraw funds
ITreasuryFactory
Interface for treasury deployment.
Functions:
registerTreasuryImplementation()- Register implementationapproveTreasuryImplementation()- Approve implementationdisapproveTreasuryImplementation()- Disapprove implementationremoveTreasuryImplementation()- Remove implementationdeploy()- Deploy treasurygetTreasuryAddress()- Get implementation address
IReward
Interface for reward management.
Functions:
getReward()- Get reward detailsaddRewards()- Add rewardsremoveReward()- Remove rewardgetAllRewards()- Get all rewards
IItem
Interface for item registry.
Functions:
getItem()- Get item detailsaddItem()- Add item to registry
ICampaignData
Data structure interface for campaign information.
Structs:
CampaignData- Launch time, deadline, goal amountConfig- Treasury factory, token, fee, identifierReward- Reward configuration
Usage
Interfaces are used for:
- Type Safety - Ensure contracts implement required functions
- Integration - Interact with contracts through defined interfaces
- Upgradeability - Allow implementation changes while keeping interface
- Testing - Mock contract behavior in tests
Best Practices
Using Interfaces for Integration
// Import interface
import { ICampaignInfo } from './interfaces/ICampaignInfo';
// Use interface for type checking
async function getCampaignInfo(address: string): Promise<ICampaignInfo> {
return await ethers.getContractAt('ICampaignInfo', address);
}
// Type-safe function calls
const campaign = await getCampaignInfo(campaignAddress);
const goal = await campaign.getGoalAmount(); // Type-safe!
Interface-Based Development
// Define interface in TypeScript for frontend
interface ICampaignInfo {
owner(): Promise<Address>;
getLaunchTime(): Promise<number>;
getDeadline(): Promise<number>;
getGoalAmount(): Promise<BigNumber>;
getTotalRaisedAmount(): Promise<BigNumber>;
paused(): Promise<boolean>;
cancelled(): Promise<boolean>;
}
Next Steps
For detailed documentation of each contract that implements these interfaces:
- CampaignInfo - Implements ICampaignInfo
- CampaignInfoFactory - Implements ICampaignInfoFactory
- GlobalParams - Implements IGlobalParams
- TreasuryFactory - Implements ITreasuryFactory
- AllOrNothing - Implements ICampaignTreasury and IReward