How It Works
SLASettle provides deterministic, permissionless smart contract settlement on Stellar Soroban. Settlement is not automatically scheduled; a party must submit trigger_settlement after quorum is reached.
End-to-End System Flow
text
+------------------+ Locks Bond +-------------------------+
| Service Provider | --------------------------> | sla_vault |
+------------------+ create_sla(..., endpoint_hash, bond) +---------------+
^
| Cross-contract read:
| get_round_tally(sla_id, round_id, endpoint_hash)
v
+------------------+ HTTP Health Probe +-------------------------+
| Watcher Nodes | --------------------------> | watcher_registry |
| (Registered Set) | submit_check(..., vote) +-------------------------+
+------------------+
|
| Downtime Detected & Quorum Reached (votes_down >= quorum_threshold)
v
+------------------+ trigger_settlement(...) +-------------------------+
| Anyone / Keeper | --------------------------> | sla_vault |
+------------------+ (Permissionless) +-------------------------+
|
| Payout penalty
v
+-------------------------+
| Beneficiary |
| (Direct Transfer) |
+-------------------------+The Five Core Components
1. watcher_registry (Soroban Smart Contract)
- Role: Maintains watcher authorization and collects per-round health attestations.
- State: Tracks registered watcher addresses, checks, and raw tallies (
votes_up,votes_down) for each(sla_id, round_id, endpoint_hash)tuple. - Responsibilities:
- Validates caller authorization: Only registered watchers can submit checks.
- Enforces duplicate prevention: One check per watcher per SLA round, regardless of the endpoint hash submitted.
- Accepts only the ledger-derived current round or the immediately preceding round. Rounds have a fixed 60-second schedule.
- Implements contract pause controls for emergency operations.
- Design Boundary: The registry has no knowledge of quorum requirements, token transfers, or penalty amounts; it is strictly an attestation and vote tallying engine.
2. sla_vault (Soroban Smart Contract)
- Role: Manages SLA configurations, escrows token collateral, and executes payouts.
- State: Stores the provider, token, endpoint commitment, bond, descriptive uptime target, quorum, fixed per-round penalty, beneficiary, status, bond balance, and settled-round records.
- Responsibilities:
- Escrows tokens upon SLA creation via Stellar Asset Contract (SAC) transfers.
- Accepts bond top-ups from the provider.
- Reads
watcher_registry.get_watcher_countwhen validating SLA creation andget_round_tally(sla_id, round_id, endpoint_hash)when settling. - Determines if
votes_down >= quorum_threshold. - Executes immediate token transfers to the beneficiary when quorum is satisfied.
- Enforces strict two-step cancellation (
cancel_slafollowed bywithdraw_remaining_bond).
3. Watcher Daemon (Go Autonomous Node)
- Role: Off-chain monitoring agent run by watcher operators.
- Operation:
- Queries
watcher_registry.has_watcher_voted(sla_id, round_id, watcher_address)to avoid duplicate transactions. - Makes one HTTP GET request per check.
HTTP_TIMEOUT_SECONDSbounds the request (10 seconds by default). - Classifies a response as
Upwhen its status code is belowHTTP_EXPECT_MAX_STATUS(400 by default); a status at or above the configured threshold isDown. - Classifies timeouts and other request failures as
Down. It does not inspect response-body content or use response latency as a classification input. - Signs and broadcasts
submit_check(watcher, sla_id, round_id, endpoint_hash, status)on Stellar Testnet using its registered Stellar keypair.
- Queries
4. Indexer Service (Cloudflare Workers / Serverless)
- Role: Off-chain event ingestion and fast query cache.
- Operation:
- Polls Soroban RPC for events emitted by
watcher_registryandsla_vault(SlaCreated,BondToppedUp,CheckSubmitted,SettlementPaid,SlaCancelled,BondWithdrawn). - Stores structured event records in D1 / SQLite database.
- Exposes RESTful endpoints for SLA status, round history, watcher activity, and settlement logs.
- Serves as a read optimization layer; it never writes to contracts or holds signing keys.
- Polls Soroban RPC for events emitted by
5. SDK & Web Console (TypeScript / Next.js)
- Role: Developer library and human operator interface.
- Operation:
@slasettle/sdkabstracts XDR encoding, simulation, contract invocation, and RPC interaction.apps/weblets providers create and top up SLAs, registered watchers inspect rounds, and beneficiaries monitor status and trigger settlements via Freighter.- Watcher registration is an administrator-authorized
watcher_registry.register_watchercontract operation. The Web console has no registration workflow, and watchers cannot self-register.
Permissionless Settlement Execution
Settlement execution is intentionally permissionless:
rust
pub fn trigger_settlement(
env: Env,
caller: Address,
sla_id: u64,
round_id: u64
) -> Result<(), Error>- The
callerparameter is not authenticated withcaller.require_auth(). - Anyone (the beneficiary, an automated keeper bot, a watcher, or any third party) can invoke
trigger_settlement. - Settlement criteria are strictly evaluated on-chain:
- The SLA must be in
Activestatus. - The round must not have been previously settled (
is_round_settled == false). votes_downretrieved from the registry must be greater than or equal toquorum_threshold.- The bond balance must be greater than zero.
- The SLA must be in
- If all conditions pass,
min(penalty_per_breach, remaining_bond)is transferred directly from the vault to the beneficiary.
The Web application requires a service endpoint and commits its 32-byte endpoint hash when creating an SLA. The raw URL is not stored on-chain. Endpoint commitments isolate tally counts but do not prove honest HTTP observations. The uptime_target_bps field is descriptive; it does not calculate monthly aggregate uptime. Contract rounds are fixed at 60 seconds.