GlobalParams contract is the central configuration contract for the Oak Network protocol. It manages protocol-wide parameters, platform listings, fees, and administrative access control.
Overview
Key Features
- Protocol Administration: Centralized protocol admin for emergency operations
- Platform Management: List, delist, and configure platforms
- Fee Configuration: Manage protocol and platform fees
- Token Management: Set default token address for campaigns
- Platform Data: Store platform-specific metadata
- Access Control: Role-based permissions for protocol and platform admins
State Variables
Protocol Configuration
| Variable | Type | Description |
|---|---|---|
s_protocolAdminAddress | address | Protocol administrator address |
s_tokenAddress | address | Default campaign token address |
s_protocolFeePercent | uint256 | Protocol fee percentage |
Platform Management
| Variable | Type | Description |
|---|---|---|
s_platformIsListed | mapping(bytes32 => bool) | Whether platform is listed |
s_platformAdminAddress | mapping(bytes32 => address) | Platform admin address |
s_platformFeePercent | mapping(bytes32 => uint256) | Platform fee percentage |
s_numberOfListedPlatforms | Counters.Counter | Total number of listed platforms |
Platform Data
| Variable | Type | Description |
|---|---|---|
s_platformDataOwner | mapping(bytes32 => bytes32) | Platform data ownership mapping |
s_platformData | mapping(bytes32 => bool) | Platform data key mapping |
Functions
Platform Management
Enlist Platform
platformHash: Unique platform identifierplatformAdminAddress: Platform administrator addressplatformFeePercent: Platform fee percentage
- Lists the platform in the protocol
- Sets platform administrator
- Configures platform fee
- Emits
PlatformEnlistedevent
- Only callable by owner
- Platform must not already be listed
- Admin address must be non-zero
Delist Platform
platformHash: Platform identifier to delist
- Removes platform from listings
- Emits
PlatformDelistedevent
- Only callable by owner
- Platform must be listed
Check If Platform Is Listed
platformHash: Platform identifier
- True if platform is listed
Get Number Of Listed Platforms
- Total number of listed platforms
Protocol Configuration
Get Protocol Admin Address
- Protocol administrator address
Update Protocol Admin Address
newAdminAddress: New protocol admin address
- Updates protocol admin
- Emits
ProtocolAdminAddressUpdatedevent
- Only callable by owner
- Address must be non-zero
Get Token Address
- Default campaign token address
Update Token Address
newTokenAddress: New token address
- Updates default token address
- Emits
TokenAddressUpdatedevent
- Only callable by owner
- Address must be non-zero
Get Protocol Fee Percent
- Protocol fee percentage
Update Protocol Fee Percent
newFeePercent: New protocol fee percentage
- Updates protocol fee
- Emits
ProtocolFeePercentUpdatedevent
- Only callable by owner
Platform Configuration
Get Platform Admin Address
platformHash: Platform identifier
- Platform admin address
Update Platform Admin Address
platformHash: Platform identifiernewAdminAddress: New admin address
- Updates platform admin
- Emits
PlatformAdminAddressUpdatedevent
- Only callable by platform admin
- Address must be non-zero
Get Platform Fee Percent
platformHash: Platform identifier
- Platform fee percentage
Update Platform Fee Percent
platformHash: Platform identifiernewFeePercent: New platform fee percentage
- Updates platform fee
- Only callable by platform admin
Platform Data Management
Add Platform Data
platformHash: Platform identifierplatformDataKey: Data key to add
- Stores platform data key
- Emits
PlatformDataAddedevent
- Only callable by platform admin
- Data key must not already exist
Remove Platform Data
platformHash: Platform identifierplatformDataKey: Data key to remove
- Removes platform data key
- Emits
PlatformDataRemovedevent
- Only callable by platform admin
Check Platform Data
platformHash: Platform identifierplatformDataKey: Data key to check
- True if data key exists
Modifiers
notAddressZero
onlyPlatformAdmin
platformHash: Platform identifier
Events
PlatformEnlisted
PlatformDelisted
ProtocolAdminAddressUpdated
TokenAddressUpdated
ProtocolFeePercentUpdated
PlatformAdminAddressUpdated
PlatformDataAdded
PlatformDataRemoved
Errors
GlobalParamsInvalidInput
GlobalParamsPlatformAlreadyListed
GlobalParamsPlatformNotListed
Usage Examples
Platform Registration
Protocol Configuration
Platform Management
Querying Platform Data
Campaign Creation Flow
Security Considerations
Access Control
- Owner Only: Critical operations (enlist/delist platforms, update protocol params) restricted to owner
- Platform Admin: Platform-specific configurations managed by platform admins
- Protocol Admin: Emergency and maintenance operations
Input Validation
- Non-Zero Addresses: All address inputs validated for non-zero values
- Fee Limits: Consider implementing reasonable fee bounds
- Platform Validation: Platform listing verified before operations
Upgradeability
- Owner Transfer: Ownership can be transferred to new admin
- Fee Changes: Fee percentages can be updated without redeployment
- Platform Changes: Platforms can be delisted without affecting existing campaigns
Integration Notes
With CampaignInfoFactory
With Campaign Contracts
Event Monitoring
Best Practices
Fee Management
- Set reasonable fee percentages (typically 1-10%)
- Document fee structure clearly
- Consider implementing fee limits in contract
Platform Administration
- Use multi-sig wallets for platform admins
- Keep admin keys secure
- Monitor platform configurations regularly
Event Logging
- Listen to all events for audit trail
- Store event data off-chain
- Implement alerting for critical changes
Next Steps
- CampaignInfo - Campaign contract
- CampaignInfoFactory - Factory contract
- TreasuryFactory - Treasury management
- Platform Integration - Platform setup guide