Dry-run scripts that exercise the full pipeline: x402-sessions SDK → facilitator HTTP API → on-chain Soroban SAC approve + transfer_from.
Uses the native XLM SAC as the payment asset so you don't need testnet USDC — just friendbot XLM.
# from this directory
npm install1. Start the facilitator (in a separate terminal):
cd ../facilitator && npm run dev2. Generate & fund user + recipient keypairs (one-time):
npm run genWrites .env with USER_SECRET, RECIPIENT_PUBLIC, etc. Both accounts are friendbot-funded with 10,000 XLM each.
3. (Optional) Check everything is ready:
npm run status4. Run the dry-run:
npm run dry-runThis will:
- Call
createSession(...)from thex402-sessionsSDK. That signs & submits an on-chain SACapprove(user, facilitator, 10 XLM, expiration_ledger)transaction, then registers the session with the facilitator viaPOST /sessions. - Call
POST /settleon the facilitator three times in a row withamount = 0.1 XLM. Each call:- Re-verifies the session in the facilitator (cap, expiry, recipient, per-call limit)
- Debits the session in sqlite atomically
- Executes
transfer_from(facilitator, user, recipient, 0.1 XLM)on-chain
- Fetches final session state via
GET /sessions/:idand prints the recipient balance delta observed from Horizon.
━━━ x402-sessions dry-run ━━━
facilitator: http://localhost:4021
user: G...
recipient: G...
asset: CDLZ... (native XLM SAC)
cap: 10.0000000 XLM
per call: 0.1000000 XLM × 3
✓ facilitator reachable
recipient balance before: 10000.0000000 XLM
[1] createSession — signing SAC approve on-chain...
✓ session: <uuid>
spender: G...<facilitator>
cap: 100000000 stroops
spent: 0 stroops
expires: ledger <n>
[1] POST /settle — 0.1000000 XLM...
✓ tx: <hash>
remaining: 99000000 stroops
[2] POST /settle — 0.1000000 XLM...
✓ tx: <hash>
remaining: 98000000 stroops
[3] POST /settle — 0.1000000 XLM...
✓ tx: <hash>
remaining: 97000000 stroops
[state] GET /sessions/:id
cap: 100000000
spent: 3000000
expiry: ledger <n>
recipient balance after: 10000.3000000 XLM
delta: +0.3000000 XLM (expected +0.3000000)
━━━ dry-run complete ✓ ━━━
| Script | Purpose |
|---|---|
npm run gen |
Generate + friendbot-fund user and recipient keypairs |
npm run status |
Check facilitator liveness and keypair balances |
npm run dry-run |
Full end-to-end flow: createSession + 3 settles + verify on-chain |