See also: API Reference Examples — executable TypeScript walkthroughs.
The Business
TechForge is a technology platform that helps hardware startups raise funds from their community. Unlike all-or-nothing crowdfunding, TechForge uses a keep-what’s-raised model: creators keep whatever they raise, even if they don’t hit their goal. This works well for hardware projects where any amount of funding helps move the project forward. TechForge also lets backers add tips to their pledges, charges payment gateway fees on each pledge, and allows creators to make partial withdrawals during the campaign (with platform approval) to cover manufacturing costs before the deadline. Tips are collected by the platform viaclaimTip and sent to the configured platform tip recipient.
Why Oak?
TechForge needs:- Flexible funding — creators keep whatever is raised, no all-or-nothing threshold
- Partial withdrawals — creators can withdraw funds mid-campaign with platform approval
- Tips — backers can tip on top of their pledge; tips are claimable separately
- Payment gateway fees — per-pledge fees recorded on-chain for transparent accounting
- Configurable fee structure — flat fees, percentage fees, and cumulative fee caps
- Refund delay — backers can refund, but only after a configurable delay period post-deadline
- Reward tiers — like all-or-nothing, but with the flexibility of partial delivery
Oak Contracts Used
| Contract | Purpose |
|---|---|
| CampaignInfoFactory | Creates campaign instances with metadata, goal, and deadline |
| CampaignInfo | Stores campaign state, pledge NFTs, platform/fee configuration |
| TreasuryFactory | Deploys the KeepWhatsRaised treasury for the campaign |
| KeepWhatsRaised | Holds pledged funds; supports partial withdrawals, tips, configurable fees |
Multi-token support
Campaigns accept a whitelist of ERC-20s resolved from the campaign currency; each pledge and withdrawal namespledgeToken / token explicitly, and the treasury enforces isTokenAccepted. Balances, tips, gateway fees, and withdrawals are tracked per token contract (each token’s decimals). Examples below use USDC; TechForge can enable additional accepted tokens the same way—GlobalParams maintains currencyToTokens (initialize, then addTokenToCurrency / removeTokenFromCurrency); campaign.getAcceptedTokens() lists what a given campaign accepts after creation.
How KeepWhatsRaised Differs from AllOrNothing
| Feature | AllOrNothing | KeepWhatsRaised |
|---|---|---|
| Funding outcome | Goal met = creator gets funds; goal not met = full refund | Creator keeps whatever is raised |
| Partial withdrawals | Not supported | Supported with platform approval |
| Tips | Not supported | Backers can tip; platform claims tips separately |
| Payment gateway fees | Not supported | Per-pledge fee tracking via setPaymentGatewayFee |
| Treasury configuration | Not needed | Required — delays, refund policy, fee structure |
| Refund timing | Immediate after deadline (if goal not met) | After deadline + configurable refund delay |
| Withdrawal approval | Not needed | Platform must call approveWithdrawal first |
| Fund claiming | withdraw() by anyone | claimFund() by platform after claim delay |
Roles
| Role | Who | Actions |
|---|---|---|
| Platform Admin | TechForge backend | Configures treasury, approves withdrawals, claims tips/funds |
| Creator | Lena (hardware startup founder) | Creates campaign, adds rewards, withdraws approved amounts |
| Backer | Community supporters | Pledges with/without rewards, can tip, claims refund after delay |
Integration Flow
Step 1: Create the campaign
Lena wants to fund her open-source IoT sensor kit. She needs $15,000 ideally but any amount helps. TechForge creates the campaign on-chain.CampaignInfo address. Two approaches are available — prefer the receipt-based one when you have the receipt in hand.
Approach 1 — Decode CampaignCreated from the receipt (recommended). Deterministic and works immediately, regardless of RPC indexing lag.
identifierToCampaignInfo (convenience). Handy when you only have the identifier hash and did not keep the receipt.
Step 2: Deploy the KeepWhatsRaised treasury
TechForge deploys a KWR treasury for Lena’s campaign. Implementation ID1 = KeepWhatsRaised.
Step 3: Configure the treasury
This is unique to KeepWhatsRaised — the platform must configure delays, refund policy, and fee structure before the treasury is operational.Step 4: Add reward tiers
Lena defines two reward tiers.Step 5: Backers pledge with tips
Backers pledge to Lena’s campaign. KWR supports tips (on top of the pledge), which go directly to the platform. Pledge with a reward and a tip:
Role: Any caller (backer) — pledgeForAReward is permissionless but time-gated (must be within the campaign window).
Role: Any caller (backer) — pledgeWithoutAReward is permissionless but time-gated.
Step 5b: Platform records payment gateway fees
Role: Platform Admin —Platforms that charge on-ramp or payment processing fees can record them on-chain for transparent accounting. There are two approaches: Record a gateway fee for an existing pledge:setPaymentGatewayFeeandsetFeeAndPledgeare admin-gated (onlyPlatformAdmin). These are called by the platform backend, not by the backer.
Step 6: Mid-campaign partial withdrawal
Lena needs funds to order components from her supplier. TechForge approves a partial withdrawal. Platform approves the withdrawal:withdrawalDelay seconds since approval, unless the delay is 0 in configureTreasury for a walkthrough):
Step 7: Monitor campaign progress
TechForge’s dashboard shows live progress with all KWR-specific metrics.Step 8: Disburse fees
After the campaign, protocol and platform fees are distributed.Step 9: Platform claims tips
Tips are claimed separately by the platform. TheclaimTip function transfers accumulated tips to the platform tip recipient (configured during platform enlistment).
Step 10: Platform claims remaining funds
After the deadline + claim delay period, the platform claims any remaining funds for the creator.Step 11: Backer claims refund (after refund delay)
If a backer wants a refund, they can claim one — but only after the deadline + the configured refund delay (14 days in this example). Before callingclaimRefund, the backer must approve the treasury to manage their pledge NFT. Pledge NFTs live on the CampaignInfo contract, so approve is called on the CampaignInfo entity:
Optional: Update campaign parameters
KWR allows updating the deadline and goal mid-campaign (subject to config lock period).Architecture Diagram
TechForge Keep-What’s-Raised Campaign FlowKey Takeaways
configureTreasuryis mandatory and unique to KWR — it sets withdrawal delays, refund delays, and the full fee structure before the treasury operates- Partial withdrawals let creators access funds mid-campaign, but require explicit platform approval via
approveWithdrawal() - Tips are a separate fund pool claimed via
claimTip(), distinct from pledges - Payment gateway fees are tracked per-pledge with
setPaymentGatewayFee()or combined with the pledge insetFeeAndPledge() - Refund delay protects creators from last-minute refund rushes — backers can only refund after deadline + configured delay
- Three claim methods serve different purposes:
claimFund()for main funds,claimTip()for tips,claimRefund()for backers withdraw()takes a specific token and amount, unlike AllOrNothing wherewithdraw()sweeps everything- Multi-token — pledges and withdrawals name the ERC-20 explicitly; only whitelisted tokens are accepted; accounting is per token
- Campaign parameters are updatable (
updateDeadline,updateGoalAmount) subject to config lock period