Skip to content
thanreizPublic

About

Programmable disaster-relief disbursement on Stellar with Soroban escrow and a weather oracle. 2nd Place, Stellar APAC Hackathon 2026.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Celerity

Celerity

Relief that moves.

A programmable disaster-disbursement rail on Stellar — many funders, one signed weather trigger, instant payouts to registered farmers.

Stellar Rust React Testnet

Soroban Vite Ed25519 SEP-31 Tests CI


Celerity

Celerity is a programmable disaster-disbursement rail on Stellar. Funders deposit into a shared on-chain escrow, each with an earmarked sub-pool and its own release rule. When an objective, signed weather event (a typhoon signal meeting a 2-of-3 oracle threshold) fires, the smart contract releases payouts automatically to pre-registered farmers, cashes out to PHP through a Stellar anchor, and logs every movement so each funder can see exactly where its money went. No agency hand-off, no physical check, no waiting.

It is not a crop insurer and not a faster claims processor — it is the multi-funder, cross-border settlement layer underneath them.

Key links


Problem

When a typhoon destroys a farmer's crop, the money to help them recover usually already exists — in a national crop-insurance fund, a regional disaster pool, or an NGO earmark. What's slow and lossy is the last mile.

Pain point What it costs
Payouts distributed as physical checks at regional offices Farmers wait weeks after the claim is even approved
Single-funder, peso-only insurers Foreign USD disaster capital can't reach a farmer directly
No way for an outside funder to verify disbursement Money routes through agencies with no audit trail
Uninsured / unregistered farmers No fast path at all

The root problem: the money exists, but turning it into cash in a farmer's hands takes layers of intermediaries. Celerity collapses that into one flow — fund, trigger, pay.

Solution

Funders deposit into a shared Soroban escrow, each deposit earmarked as a sub-pool with its own payout rule and recipient scope. Authorized oracles submit a threshold-signed weather event (region, typhoon signal). The contract verifies enough Ed25519 signatures and compares numbers — it never reads or interprets a document. For every sub-pool whose condition the event meets, it releases the payout only to farmers whose registry region matches that pool's region, on the funder's schedule, and logs a per-funder ledger entry. Payouts convert to spendable pesos through a Stellar anchor at the edge.

Core claim: a national insurer, a regional fund, and a foreign foundation can co-fund the same typhoon trigger and pay a farmer instant, spendable pesos — with no agency hand-off and every peso auditable.

How It Works

  1. Funders deposit into earmarked sub-pools. Each deposit creates a sub-pool: a balance plus a rule (region, signal threshold, payout, installment schedule). Balances never commingle; one funder's release, pause, or exhaustion never touches another's.

  2. An LGU/co-op admin registers farmers. register_farmer(address, region, source) maintains the beneficiary list (source tags provenance — RSBSA / COOP / NGO). The contract pays only registered addresses in the triggered region — it doesn't decide who's a farmer, it pays a verified list.

  3. A multi-sig weather bulletin enters the contract. Authorized oracles each sign region · signal · nonce with Ed25519; report_event verifies a threshold of signatures against constructor-pinned keys (live demo: 2-of-3). A real typhoon hits many regions at once, so the app ingests a bulletin and reports one event per region.

  4. Settlement releases every matching sub-pool at once. settle_event iterates matching sub-pools and pays each registered farmer — idempotent on (event, farmer, pool) so a replay never double-pays, and flag-not-fail so a dry pool is marked Exhausted and skipped rather than reverting everyone else's release.

  5. Farmers claim recurring installments on schedule. Recurring pools release the first installment at settlement; the farmer pulls the rest with claim on the pool's own cadence. claim requires the farmer's current registry region to match the pool's region — remove → re-register elsewhere cannot finish an old schedule.

  6. Value cashes out to PHP and every release is logged. Released value routes through a SEP-31 anchor to spendable pesos, and funder_ledger gives each funder a per-release, on-chain record.

Stellar Integrations

Celerity isn't "an app with a Stellar payout at the end" — Stellar is the trust layer the whole design leans on. What's actually in use, all live on Testnet:

# Integration Where / how
1 Soroban smart contract The full escrow, trigger, and settlement logic runs as a Rust contract on Stellar, not a backend server — funds and rules live on-chain.
2 Stellar Asset Contract (SAC) transfers Payouts move with token::TokenClient::new(&e, &get_token(&e)).transfer(...) — native Stellar asset transfers, not an internal ledger entry.
3 On-chain multi-sig verification (Ed25519) report_event verifies a threshold of ed25519_verify checks against constructor-pinned oracle keys — no single agency key can fire payouts alone.
4 Per-address authorization Every state-changing call (deposit, register_farmer, claim, …) requires .require_auth() from the correct Stellar account — funder isolation is enforced by the protocol, not just app logic.
5 On-chain persistent storage Sub-pools, farmer registry, and settled-event keys live in e.storage().persistent() / .instance() — the state judges can audit is the same state the contract runs on.
6 On-chain event log Every release publishes via e.events().publish(...), giving each funder a verifiable, independent release trail — not an app database log.
7 Ledger-timestamped scheduling Recurring installment cooldowns are enforced against e.ledger().timestamp(), so claim pacing can't be gamed by a client clock.
8 SEP-31 anchor cash-out (stub) The PHP off-ramp is modeled on Stellar's own cross-border payment standard, SEP-31 — the shape of the integration is real, the receiver is a labeled mock for the hackathon.

Everything above except #8 is live, unmocked infrastructure on Stellar Testnet — verifiable per-transaction on stellar.expert.

Inter-Contract Call

settle_event calls the CLTY Stellar Asset Contract (CDLZMFYC7E2SJLJY4XTEWBUVBQSJXXKJFTZCXKLD4EYOQUWG54TXMKWA) via token::TokenClient::new(&e, &get_token(&e)).transfer(...) for every farmer payout. This is a cross-contract invocation — visible as a nested invoke_contract sub-invocation inside the settlement transaction.

Proof tx: 3afd494d… (expand the Operations → sub-invocations tree to see CAYCM4JG… calling CDLZMFYC…)

CLTY SAC contract: CDLZMFYC…

Key transaction hashes

Action Tx hash
CLTY SAC deploy ef35bf32…
Celerity contract deploy (phase 14) 329ba311…
First report_event (typhoon signal 4, Region V) 7438f55e…
First settle_event — inter-contract call proof 3afd494d…

Features

Smart Contract (live on Testnet)

  • Shared escrow, isolated sub-pools — many funders, one contract; deposit, top_up, withdraw_unspent, pause_pool / resume_pool, all funder-auth scoped.
  • Multi-sig oracle trigger (2-of-3) — report_event takes indexed Ed25519 signatures (OracleSig { key_index, signature }), enforces the constructor threshold (duplicate key_index values count once), and rejects replays via nonce stored permanently on-chain. The contract compares numbers, never reads a bulletin document. Inspect keys anytime with oracle_config().
  • Idempotent multi-funder release — settle_event pays every matching pool once, keyed on (event_id, farmer, pool_id); a re-run after a top-up pays only whoever was missed. Demo-scale: one transaction scans 1..NextPoolId × farmers in the region; paginate before real-scale use.
  • Flag-not-fail — an underfunded pool is flagged Exhausted and skipped; one funder's dry pool never reverts another's payout. top_up cures the flag.
  • Recurring installments — claim pulls the next tranche on the pool's cadence; hard-stops at the installment count; a paused pool blocks the claim; the farmer's current registry region must match the pool's region.
  • Farmer registry — admin-auth register_farmer / remove_farmer, region-keyed, with on-chain source tagging (RSBSA / COOP / NGO) for APAC registry provenance.
  • Oracle config view — oracle_config() returns constructor-pinned keys + threshold.
  • Per-funder ledger — funder_ledger and one release event per (funder, farmer).
  • On-chain transparency — every mutator (deposit, top_up, withdraw, pause, resume, reg_farm, rm_farm, event, release, exhausted, claim) emits a Soroban contract event. Combined with funder_ledger, the full disbursement history is verifiable directly on-chain — not in any private database Celerity controls. Judges can inspect all events on stellar.expert.

Funder Console (React)

  • Login-first, GCash-style — pick an institution (ADB APDRF / PCIC), then an escrow hero, circular quick-actions, and a release feed grouped by signed event.
  • Strict funder isolation — the dashboard is scoped to the logged-in funder; the other funder's pools and ledger never appear.
  • Escrow pools — island-grouped (Luzon / Visayas / Mindanao), status-mix pills, plain-language release rules, and a typhoon-context banner.
  • Trigger Typhoon — drop a signed PAGASA-style JSON bulletin; the app shows region-by-region what will settle vs. skip, then signs and settles each matching region.
  • Farmers registry — read-only for funders, with an explicit LGU registrar mode that signs with the admin key.

Farmer App + Transparency

  • Connect — brand-first “Is this you?” screen: dove lockup + Relief that moves, farmer name, full region label (e.g. Region V — Bicol), optional account reveal, and a quiet multi-farmer switch for the demo slate.
  • Farmer shell — wallet total, receipts, recurring-installment claims, Quick Help / Cash Out / tx detail as isolated overlays (Home nav never bleeds through), and a labeled SEP-31 anchor cash-out to PHP.
  • Brand chrome — dove favicon in the browser tab; splash and Connect share the same mark and tagline as the live site.
  • Public transparency ledger — every release across all funders, no login required.

Honest Stubs (clearly labeled)

  • Live PAGASA/JMA feed — a Node.js Ed25519 signer stands in for the authorized weather feed.
  • Licensed anchor cash-out — a SEP-31 receiver mock stands in for a licensed VASP (e.g. Coins.ph). Everything on-chain is real; only the fiat conversion is simulated.

Architecture

flowchart TD
    funder["Funders (ADB APDRF, PCIC, NGOs)"] -->|deposit| pool["Soroban escrow: earmarked sub-pools"]
    lgu["LGU / co-op admin"] -->|register_farmer| registry["Farmer registry (region-keyed)"]
    pagasa["PAGASA / JMA signal"] --> signer["Oracle signer (Ed25519, demo stub)"]
    signer -->|report_event: region, signal, nonce, sig| contract["Celerity contract"]
    pool --> contract
    registry --> contract
    contract -->|settle_event: idempotent, flag-not-fail| release["Release to farmers"]
    release --> ledger["Per-funder ledger + release events"]
    release --> anchor["SEP-31 anchor stub → PHP"]
    anchor --> farmer["Farmer: spendable pesos"]
Loading

Tech Stack

Layer Technology
Smart contract Soroban (Rust), deployed to Stellar Testnet
Frontend React + Vite, @stellar/stellar-sdk (≥ 16), design tokens + shared CSS
Oracle signer Node.js Ed25519 multi-sig (2-of-3 demo keys standing in for PAGASA/JMA/NDRRMC)
Settlement token Native XLM SAC (a USD stablecoin in the production narrative)
Anchor Stubbed SEP-31 receiver for USD/stablecoin → PHP
Network Stellar Testnet — every on-chain step verifiable on stellar.expert
Contract address CAYCM4JG5NCXGQLQOPL6AK3CVDJFJIQYAQGMU64L5RMNYU7K3SHWJGZF

Repo Layout

contracts/celerity/       Soroban smart contract (Rust)
  src/lib.rs              Data model + full function surface
  src/test.rs            Unit / adversarial tests (idempotency, isolation, dry-pool)
celerity-web/            React frontend
  public/                Brand assets (dove favicon, logo lockup)
  src/pages/funder/      Login, home, pools, oracle (bulletin drop), ledger, registry, settings
  src/pages/farmer/      Farmer app: splash, connect, home, activity, cash-out, profile
  src/pages/transparency/ Public transparency ledger
  src/design/            Design-system components + tokens.css
  src/lib/               celerity.js (contract client), regions.js, funders.js, anchor.js
oracle/                  Node.js Ed25519 oracle signer (demo stub for the weather feed)
tools/seed-demo.mjs      Repeatable demo-slate seed (pools + farmers, no event fired)
screenshots/             Product screenshots (refresh with `node tools/capture-screenshots.mjs`)
docs/                    Categorized product + hackathon docs ([docs/README.md](docs/README.md))
DEMO-SCRIPT.md           Stage demo checklist
tools/capture-screenshots.mjs  Playwright capture of live farmer + funder screens
deployments.json         Public Testnet deployment metadata + contract-id history

Screenshots

Every screen and sub-screen of the live app, captured from the deployed build. Full-size originals are in screenshots/.

Farmer app (mobile)
Splash
Splash
Connect
Connect
Farmer home
Home
Farmer activity
Activity
Installments
Installments
Farmer profile
Profile
Relief programs
Relief programs
My region
My region
Transaction detail
Tx detail
Help
Help

Cash-out flow (SEP-31 anchor stub → PHP):

Cash-out destination
Destination
Cash-out recipient
Recipient
Cash-out amount
Amount
Cash-out confirm
Confirm
Cash-out success
Success
Funder console (desktop)
Funder login
Login (pick institution)
Funder home
Home / escrow summary
Escrow pools
Escrow pools
Create pool
Create pool
Top up
Top up pool
Farmers registry
Farmers registry
LGU registrar mode
LGU registrar mode
Trigger Typhoon, empty
Trigger Typhoon (empty)
Trigger Typhoon, parsed bulletin
Bulletin parsed
Manual single-region fallback
Manual fallback
Funder ledger
Ledger
Settings
Settings
Public transparency ledger
Public transparency ledger

Run Locally

Frontend

cd celerity-web
npm install
cp .env.example .env   # fill in: contract ID from deployments.json, demo secrets
                       # from `stellar keys show <name>` + oracle/.env
npm run dev

The UI never embeds signing secrets. Money-moving calls go through /api/* server routes (Vercel serverless + Vite dev middleware). Requires @stellar/stellar-sdk ≥ 16 (older majors can't parse current-protocol transaction metadata).

Prerequisites (contract build / deploy)

  • Rust ≥ 1.84 with the wasm32v1-none target (rustup target add wasm32v1-none)
  • Stellar CLI (cargo install stellar-cli) — this repo used v27
  • A funded Testnet identity named alice (stellar keys generate alice --network testnet --fund)

Build, test, deploy

# Build the contract to Wasm
cd contracts/celerity && stellar contract build

# Run the test suite (60 tests, adversarial cases included)
cargo test

# Deploy to Testnet. The constructor runs atomically at deploy — admin,
# oracle key set + threshold, and settlement token (SAC address) are set with
# no separate init call to front-run.
stellar contract deploy \
  --wasm target/wasm32v1-none/release/celerity.wasm \
  --source-account alice --network testnet -- \
  --admin "$(stellar keys address alice)" \
  --oracle_keys '["<64-hex pubkey 0>", "<64-hex pubkey 1>", "<64-hex pubkey 2>"]' \
  --threshold 2 \
  --token CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC

Seed a demo slate

After a fresh deploy, seed pools + farmers (leaves everything Armed with an empty ledger, so the typhoon is triggered live):

cd celerity-web && node ../tools/seed-demo.mjs

Demo Flow

  1. Open the funder console and log in as ADB APDRF. On Escrow Pools, read a plain-language rule: "When typhoon signal ≥ 3 hits Bicol → release the payout per registered farmer." (Demo amounts are small Testnet XLM shown as pesos at a fixed demo rate, so the escrow doesn't drain the demo accounts.)
  2. Tap the PCIC pill in the "Acting as" switcher (top of Escrow Pools) and watch the whole dashboard — pools, totals, ledger — re-scope to PCIC's own money. Strict funder isolation: neither funder ever sees the other's balance.
  3. In Farmers (LGU), show the registry belongs to the government, not the funders.
  4. Open Trigger Typhoon, drop the PAGASA bulletin, and watch it settle every matching region at once — one signed bulletin, many releases.
  5. Jump to the farmer app: confirm identity on Connect (name + region), then show the wallet — the money has already arrived. Every release is one click from stellar.expert; the funder Ledger matches what the farmer sees.
  6. Run the farmer's balance through the labeled SEP-31 anchor stub to spendable pesos (overlays stay above the tab bar the whole way).

Environment

celerity-web/.env (gitignored — copy from .env.example):

Variable Required Purpose
VITE_RPC_URL yes Soroban Testnet RPC (public — safe in the browser bundle)
VITE_NETWORK_PASSPHRASE yes Testnet passphrase (public)
VITE_CONTRACT_ID yes Deployed contract id from deployments.json (public)
FUNDER_SECRET yes Server-only — funder + registry admin (alice). Never use a VITE_ prefix
FUNDER2_SECRET yes Server-only — second funder (PCIC / mallory)
FARMER_SECRET yes Server-only — Mang Ramon
FARMER2_SECRET yes Server-only — Aling Nena
ORACLE_SECRET yes Server-only — oracle key index 0 (same as oracle/.env)
ORACLE_SECRET_2 yes Server-only — oracle key index 1 (required for 2-of-3)
ORACLE_SECRET_3 no Server-only — oracle key index 2 (optional third signer)

Do not set VITE_*_SECRET in Vercel Production — Vite would bake them into the public JS bundle.

Credits

Ethan Dreiz Baltazar — solo developer. Built, designed, and shipped Celerity end to end (contract, oracle stub, farmer app, funder console, and demo).

Notes

  • Never print, log, or commit a secret key. Oracle signer keys are generated and injected, never hardcoded; .env and oracle/.env are gitignored.
  • The oracle feed and the anchor cash-out are deliberate, clearly-labeled stubs — everything else (escrow, trigger verification, multi-funder release, registry, ledger, claim) is real and live on Testnet.
  • settle_event is demo-scale: one transaction iterates 1..NextPoolId × farmers in the triggered region. Pagination is roadmap before any real-money pilot.
  • Admin is rotatable via set_admin; oracle keys + threshold and the settlement token are constructor-pinned for the hackathon (inspect with oracle_config()).
  • Contract IDs are public and safe to commit; they live in deployments.json, with every prior redeploy preserved under previous_contract_ids.

Status: Demo-ready on stellar-celerity.me. A signed typhoon bulletin releases multiple independently-funded sub-pools to registered farmers, live on Stellar Testnet, with a per-funder ledger and a labeled SEP-31 cash-out. Farmer Connect is brand-first (Relief that moves + full region label); overlays no longer bleed under the tab bar; the dove mark is the site favicon.

About

Programmable disaster-relief disbursement on Stellar with Soroban escrow and a weather oracle. 2nd Place, Stellar APAC Hackathon 2026.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages