Documentation / Implementation
Implementation
01System architecture
AnchorFX is a full-stack settlement layer: two Soroban smart contracts on Stellar, a Next.js frontend, and a thin API layer that reads on-chain state and exposes it over REST and SSE.
Architecture
┌──────────────┐ ┌────────────────┐
│ Frontend │──┐ │ Next.js API │
│ (Next.js) │ │ │ (REST + SSE) │
└──────────────┘ │ └───────┬────────┘
│ │
│ ┌──────▼────────┐
└──>│ Soroban RPC │
└──────┬────────┘
│
┌──────────────┼──────────────┐
▼ ▼ ▼
┌────────────┐ ┌────────────┐ ┌─────────────┐
│ Escrow │ │ FX Oracle │ │ Any SAC │
│ factory │ │ (rates) │ │ (XLM/USDC) │
└────────────┘ └────────────┘ └─────────────┘INFO
Atomicity
The escrow contract stores the FX rate at creation time; the locked funds cannot be released until both parties approve, and settlement is atomic.
02Escrow contract API
init(admin, oracle)Initialize the contract with an admin and an oracle address.
create_escrow(sender, receiver, token, amount, timeout_blocks, corridor)Create a new escrow locking funds for a corridor at the current valid oracle rate.
counterparty_approve(id)Receiver approves the escrow terms (second-party confirmation).
settle(id)Admin releases funds to the receiver at the agreed rate.
refund(id)Sender reclaims funds after the timeout when unapproved.
cancel(id)Admin cancels a stuck escrow.
get_escrow(id) / escrow_count() / list_escrows(start, limit)Read escrow state and paginate the escrow list.
pause() / unpause() / transfer_admin(new_admin)Circuit breaker and admin transfer.
03Oracle contract API
init(admin)Initialize the oracle.
set_rate(token, rate) / get_rate(token)Publish and read a rate;
get_rate reverts if expired.is_rate_valid(token) / remove_rate(token)Check validity and remove a rate.
04Escrow states
State machine
Created ──────────────> CounterpartyApproved ──> Settled
│ │
├─> Refunded (after timeout) └─> Cancelled (admin)
└─> Cancelled (admin)05Project structure
Repo layout
AnchorFX/
├── contracts/
│ ├── anchorfx-escrow/ # Escrow factory (23 tests)
│ └── anchorfx-oracle/ # FX rate oracle (4 tests)
├── frontend/
│ ├── app/ # Next.js routes + API
│ │ ├── wallet/ contract/ anchors/
│ │ ├── explorer/ rates/ status/ developers/ admin/
│ │ └── api/ # 15 REST + SSE routes
│ ├── components/ lib/ scripts/
│ └── deploy.cjs # Universal deploy script
├── docs/ # Pitch deck, screenshots, security, CSV
└── GROWTH-REPORT.md # Monthly growth report06Security review
The contracts were audited (257 findings — all critical/high/medium fixed) and hardened with per-escrow storage, checks-effects-interactions ordering, typed errors, and a pause circuit breaker. See the full Security documentation.