> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getsly.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Stellar integration architecture

> How Sly's governed settlement loop runs on Stellar today, and the integration plan for Stellar Wallets Kit, the Stellar Disbursement Platform, and Allbridge — with the build status of every component labeled.

<Note>
  **Every component on this page carries one of three status labels.** They match
  the status language used across these docs and are independently checkable
  against Sly's public evidence repo,
  [Sly-devs/stellar-evidence](https://github.com/Sly-devs/stellar-evidence) —
  on-chain transactions, signed receipts, and an offline verifier, no Sly
  login required.
</Note>

| Label                   | Meaning                                                                                                                                          |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| 🟢 **Live**             | Running on Stellar testnet today (`stellar:testnet`). Mainnet (`stellar:pubnet`) ships with production access. Verifiable via the evidence repo. |
| 🟡 **Pending external** | Code path complete and honestly surfaced in API responses; blocked on a dependency outside Sly's codebase.                                       |
| 🔵 **Planned — funded** | Not in the codebase. Deliverable of the funded tranche noted. Never presented as built.                                                          |

## System overview — the governed loop on Stellar

Every Stellar payment through Sly runs the same five-layer loop: identity is resolved, policy is decided, settlement happens on chain via the Stellar Asset Contract, and a signed receipt makes the whole decision auditable offline.

```mermaid theme={null}
flowchart LR
  A["Agent<br/>(agent_id + intent)"] --> KYA["KYA resolution<br/>tier at sign time"]
  KYA --> PD{"PolicyDecision<br/>L1 tier · L2 kill-switch · L3 cap"}
  PD -- deny --> DENY["Signed deny artifact<br/>same envelope, same HMAC"]
  PD -- approve --> SETTLE["x402 settlement<br/>USDC SAC + Soroban auth entries<br/>via the public x402.org facilitator<br/>(fees sponsored on Stellar)"]
  SETTLE --> WR["Witness receipt<br/>HMAC-SHA256 over json-sort-keys-v1"]
  WR --> EAS["Receipt anchor — EAS on Base<br/>(interim baseline)"]
  WR --> AP["Receipt anchor — AttestProtocol<br/>on Soroban"]
  WR --> KAT["KYA attestation write<br/>Soroban attestation contract"]

  classDef live fill:#e6f6ec,stroke:#1a7f37,color:#14532d
  classDef pending fill:#fff8e1,stroke:#9a6700,color:#713f12
  classDef planned fill:#eef2ff,stroke:#4f46e5,color:#312e81
  class KYA,PD,DENY,SETTLE,WR,EAS live
  class AP pending
  class KAT planned
```

🟢 The loop itself is live: `POST /v1/x402/stellar/pay` runs KYA gate → kill-switch → per-call cap → signs the Soroban auth entry with the agent's Ed25519 key → mints the witness receipt. Denied calls never touch the network and return a signed deny artifact in the same envelope shape. The receipt binds agent identity (`agent_id`, `agent_kya_tier`), key-control proof (`agent_chain_proof: "sep10"`), custody disclosure (`agent_custody_provider`), rail choice (`rail_selection.reasons`), and the policy decision under one HMAC — verifiable offline with `verify-offline.mjs`.

🟡 The AttestProtocol anchor route is wired end-to-end (signed XDR returned) and reports `status: "pending_init"` — pending upstream contract init, tracked with the AttestProtocol team. 🟢 In the interim, receipt-hash anchoring to EAS on Base Sepolia is the live baseline (network is environment-selected: sandbox anchors to Base Sepolia, production to Base mainnet — this page and the evidence repo describe the sandbox/testnet path). 🔵 KYA attestation writes to a Soroban attestation contract are a Tranche 1 deliverable.

## Building block 1 — Stellar Wallets Kit → verified agent onboarding

```mermaid theme={null}
flowchart LR
  W["Multi-wallet connect<br/>Freighter · xBull · Albedo · Lobstr"] --> C["SEP-10 bind<br/>challenge → sign → bind"]
  C --> T["KYA tier assignment"]
  T --> D["Directory listing"]
  D --> AT["KYA attestation write<br/>Soroban attestation contract"]

  classDef live fill:#e6f6ec,stroke:#1a7f37,color:#14532d
  classDef planned fill:#eef2ff,stroke:#4f46e5,color:#312e81
  class C,T live
  class W,D,AT planned
```

🟢 The middle of this flow is live today: agents bind their Stellar address via SEP-10 Web Authentication (`POST /v1/agents/:id/stellar/challenge` → sign off-screen → `POST /v1/agents/:id/stellar/bind`, verified with `WebAuth.verifyChallengeTxSigners()` from `@stellar/stellar-sdk`). A successful bind flips every subsequent receipt to `agent_chain_proof: "sep10"`; unbound agents are honestly stamped `asserted`. KYA tiering gates every settlement.

🔵 Tranche 1 puts **Stellar Wallets Kit** in front of that live path: an operator connects any supported wallet from the browser, signs the same SEP-10 challenge, and lands in the same chain-bindings table — no API scripting required. Verified agents then become discoverable (directory listing) and their tier is attested on chain (Soroban attestation contract; the live EAS-on-Base path is the interim anchoring backend).

## Building block 2 — Stellar Disbursement Platform → governed multi-agent disbursement

```mermaid theme={null}
flowchart LR
  O["Orchestrator agent"] --> RK["Per-recipient KYA"]
  RK --> BP["Batch PolicyDecision"]
  BP --> SDP["SDP submission"]
  SDP --> WRP["Witness receipt<br/>per payout"]
  WRP --> AN["SEP-24/31<br/>anchor off-ramp"]

  classDef planned fill:#eef2ff,stroke:#4f46e5,color:#312e81
  class O,RK,BP,SDP,WRP,AN planned
```

🔵 The entire SDP path is a Tranche 2 deliverable — none of it is in the codebase today. What de-risks it: every node composes primitives that are already live in the single-payment path. Per-recipient KYA is the same L1 gate, the batch PolicyDecision is the same policy engine, and the per-payout witness receipt is the same envelope + HMAC — the new work is the batch orchestration and the SDP submission itself.

**External dependency, stated plainly:** the SEP-24/31 anchor off-ramp requires an agreement with a list-approved anchor. This is a partnership blocker, not an engineering one, and Tranche 2 acceptance is scoped accordingly.

## Building block 3 — Allbridge → cross-chain settlement under one receipt

```mermaid theme={null}
flowchart LR
  I["Intent<br/>currency · amount · chains"] --> SR["selectRail()"]
  SR -- "native USDC<br/>Base ↔ Stellar" --> CCTP["CCTP route<br/>burn / mint"]
  SR -- "cross-stablecoin ·<br/>non-CCTP chains" --> AB["Allbridge Core route<br/>Soroban liquidity pools"]
  CCTP --> SPAN["Spanning receipt<br/>both chain hashes + reason codes"]
  AB --> SPAN
  SPAN --> CUST["Smart-account custody<br/>limits enforced at the rail"]

  classDef live fill:#e6f6ec,stroke:#1a7f37,color:#14532d
  classDef pending fill:#fff8e1,stroke:#9a6700,color:#713f12
  classDef planned fill:#eef2ff,stroke:#4f46e5,color:#312e81
  class SR live
  class CUST pending
  class CCTP,AB,SPAN planned
```

🟢 `selectRail()` is live: a pure decision function that intersects tenant and agent rail allow-lists, scores candidates, and returns the chosen rail plus human-readable reasons — which land in the receipt's `rail_selection` field (`picked:fee_sponsored`, `picked:cheaper_fee`, `picked:faster_finality`).

🔵 Tranche 3 extends it into a cross-chain router. **Allbridge Core** (Soroban-native liquidity pools) becomes a `selectRail()` route for cross-stablecoin transfers and chains CCTP doesn't reach; the CCTP leg covers native USDC Base ↔ Stellar (Sly's CCTP bridge service is live on other rails today; the Stellar leg is part of this tranche). Either route emits a single **spanning receipt** carrying both chain hashes and the reason codes for the route taken. 🟡 Custody enforcement at the rail rides on OZ Soroban smart accounts — the receipt-side abstraction is shipped (receipts honestly stamp `env_key` custody today); the on-chain custody contract is still being deployed.

**Soroban Trust Spine** is the name of the Tranche 3 anchoring deliverable: witness-receipt and attestation writes to Soroban attestation contracts (existing contract or self-host fallback), verified via Soroban's ed25519/secp256k1 host functions, with all Soroban contract components open-sourced (MIT).

## Component inventory

| Component                                                      | Status                                                                                         | Runs against                                                                                         | Where to verify                                                    |
| -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| x402 governed settlement (`POST /v1/x402/stellar/pay`, L1–L5)  | 🟢 Live                                                                                        | Sly API → USDC SAC via x402.org facilitator                                                          | Evidence repo §1 — headline tx on stellar.expert                   |
| SEP-10 chain binding (challenge / sign / bind)                 | 🟢 Live                                                                                        | Sly API + Horizon                                                                                    | Receipt field `agent_chain_proof: "sep10"`; evidence repo §5–§6    |
| KYA tiering + signed deny artifacts                            | 🟢 Live                                                                                        | Sly API                                                                                              | Deny artifact JSON — `/settlement/stellar`                         |
| `selectRail()` decision function                               | 🟢 Live                                                                                        | Sly API (pure function)                                                                              | `rail_selection.reasons` in every receipt                          |
| `StellarRailAdapter` (settle, balance, history, health)        | 🟢 Live                                                                                        | Horizon + Soroban RPC                                                                                | `/settlement/stellar`                                              |
| Witness receipts (HMAC over `json-sort-keys-v1`)               | 🟢 Live                                                                                        | Sly API — offline-verifiable                                                                         | `verify-offline.mjs` in the evidence repo                          |
| Dashboard surface (rail badges, receipt panel, chain bindings) | 🟢 Live                                                                                        | app.getsly.ai                                                                                        | Narrated tour in the evidence repo                                 |
| Receipt anchoring — EAS on Base (interim baseline)             | 🟢 Live                                                                                        | Base Sepolia in sandbox — environment-selected, Base mainnet in production (non-Stellar interim leg) | Anchor route, backend `eas-base`                                   |
| Receipt anchoring — AttestProtocol on Soroban                  | 🟡 Pending external — wired, pending upstream contract init                                    | Soroban RPC                                                                                          | Anchor route returns signed XDR + `status: "pending_init"`         |
| OZ Soroban smart-account custody                               | 🟡 Pending external — receipt-side abstraction shipped; on-chain contract still being deployed | Soroban                                                                                              | Receipts stamp `agent_custody_provider` honestly (`env_key` today) |
| Stellar Wallets Kit onboarding                                 | 🔵 Planned — funded (Tranche 1)                                                                | Browser + Sly API                                                                                    | —                                                                  |
| Directory listing of verified agents                           | 🔵 Planned — funded (Tranche 1)                                                                | Sly API                                                                                              | —                                                                  |
| KYA attestation write path                                     | 🔵 Planned — funded (Tranche 1)                                                                | Soroban attestation contract                                                                         | —                                                                  |
| SDP governed disbursement + SEP-24/31 anchor flow              | 🔵 Planned — funded (Tranche 2)                                                                | SDP + list-approved anchor                                                                           | —                                                                  |
| Allbridge Core route + spanning receipt                        | 🔵 Planned — funded (Tranche 3)                                                                | Allbridge Core (Soroban pools)                                                                       | —                                                                  |
| Soroban Trust Spine (native anchoring, MIT)                    | 🔵 Planned — funded (Tranche 3)                                                                | Soroban ed25519/secp256k1 host functions                                                             | —                                                                  |

## Verify these claims

* **Evidence repo:** [github.com/Sly-devs/stellar-evidence](https://github.com/Sly-devs/stellar-evidence) — 13 verified testnet settlements, 3 signed receipts, standalone verifier, sandbox HMAC key published inline.
* **Headline transaction:** [stellar.expert/explorer/testnet/tx/378e8aa9…](https://stellar.expert/explorer/testnet/tx/378e8aa99eb136c50e9ee5d7ebaca3d4f931c2b701d241fc6419f7470a4ccc12) — Soroban `invoke_host_function`, USDC SAC transfer, both G-addresses match the signed receipt.
* **Offline verification:** `node verify-offline.mjs headline-receipt.json` → `✓ SIGNATURE VALID` — 57 lines, Node built-ins only, no Sly infrastructure in the loop.

One click from this architecture page to on-chain proof. That's the trust model: verify the chain, not the presentation.
