Source: Full executable TypeScript in contract/src/examples/00-platform-enlistment/. This page summarizes the flow — read the source for complete per-step code.
The Story
NovaPay is a digital marketplace that helps independent sellers accept payments online. They want to integrate Oak Protocol to offer their merchants on-chain payment processing and crowdfunding capabilities. Before any campaign can be created or treasury deployed on their platform, NovaPay must first be enlisted as a platform on the protocol. Platform enlistment is a coordinated process between two roles:- The Protocol Admin (the Oak Network team) — who governs the GlobalParams contract and must approve every new platform joining the protocol
- The Platform Admin (NovaPay’s operations wallet) — who will manage the platform’s day-to-day configuration once enlisted, such as treasury registration, fee settings, and payment operations
Platform Hash
Every platform on Oak Protocol is identified by abytes32 value called the platform hash. It is the keccak256 hash of the platform name and remains fixed for the lifetime of the platform.
Implementation ID Layout
Each platform maintains its own mapping of implementation ID to treasury contract inside TreasuryFactory:| Implementation ID | Treasury Model | Use Case |
|---|---|---|
0n | AllOrNothing | Crowdfunding — backers get a full refund if the goal is not met |
1n | KeepWhatsRaised | Crowdfunding — the creator keeps whatever is raised, even if the goal is not met |
2n | PaymentTreasury | E-commerce — structured payments with no time restrictions |
3n | TimeConstrainedPaymentTreasury | E-commerce — same as PaymentTreasury but enforces launch time and deadline on-chain |
Role Reference
| Function | Who can call | Contract modifier |
|---|---|---|
enlistPlatform | Protocol Admin | onlyOwner |
delistPlatform | Protocol Admin | onlyOwner |
updatePlatformAdminAddress | Protocol Admin | onlyOwner |
updateProtocolFeePercent | Protocol Admin | onlyOwner |
addTokenToCurrency / removeTokenFromCurrency | Protocol Admin | onlyOwner |
setPlatformAdapter | Protocol Admin | onlyOwner |
setPlatformLineItemType / removePlatformLineItemType | Platform Admin | onlyPlatformAdmin |
updatePlatformClaimDelay | Platform Admin | onlyPlatformAdmin |
addPlatformData / removePlatformData | Platform Admin | onlyPlatformAdmin |
All get* / check* reads | Anyone | (read-only) |
Steps
Step 1: Enlist the Platform
The Protocol Admin callsenlistPlatform on GlobalParams. This single transaction sets the platform hash, admin address, fee percent, and adapter. Any other caller reverts with GlobalParamsUnauthorizedError.
Step 2: Verify the Enlistment
After the Protocol Admin enlists NovaPay, anyone with a read-only client can verify the on-chain state. No private key is needed — these are pure view calls against GlobalParams.Step 3: Register a Treasury Implementation
Now that NovaPay is enlisted, the Platform Admin registers the treasury model they want to use. Each model goes into a numbered slot (implementationId) on TreasuryFactory. Registrations are not immediately active — they sit in a pending state until the Protocol Admin approves them.
Step 4: Approve the Implementation
The Protocol Admin explicitly approves the registered implementation. This is a safety gate — the protocol team verifies the implementation contract before allowing the platform to deploy treasuries from it. Each registered slot requires its own approval call.Step 5: Verify Full Setup
Before going live, NovaPay’s admin runs a final check to confirm every piece of the onboarding is in place: the platform is listed, admin and fee values match agreed terms, and treasury implementations are registered and approved.Step 6: Optional Configuration
After core onboarding, a platform can configure additional features. These are all optional and independent — skip any you don’t need.| Section | Feature | Who Calls | Applies To |
|---|---|---|---|
| A | Line Item Types | Platform Admin | PaymentTreasury only |
| B | Claim Delay | Platform Admin | PaymentTreasury only |
| C | Platform Data Keys | Platform Admin | All treasury types |
| D | Platform Adapter | Protocol Admin | All treasury types |
| E | Protocol Admin Functions | Protocol Admin | Protocol-wide |
Multi-token currencies
GlobalParams holds currencyToTokens: bootstrapped in initialize(currencies, tokensPerCurrency), then the protocol owner can addTokenToCurrency / removeTokenFromCurrency; anyone can read getTokensForCurrency(currency). When CampaignInfoFactory creates a campaign, it reads the current token list and stores a snapshot on CampaignInfo; treasuries validate every paymentToken / pledgeToken against that cache.