SDK — Architecture
🚀 Key Architectural Modules
Agent Action Request
│
▼
┌───────────────────────────┐
│ PreFlightInterceptor │
└─────────────┬─────────────┘
│
Simulate Call via Soroban RPC
│
▼
┌───────────────────────────┐
│ CostPreChecker │
└─────────────┬─────────────┘
│
Check Fee Ceilings & Enforce Policy
│
┌────────────────────┴────────────────────┐
▼ ▼
Decision: Admissible Decision: Blocked
(Assemble & Broadcast) (Emit Telemetry & Halt)🔍 PreFlightInterceptor
Simulates contract invocations using server.simulateTransaction():
- Decodes diagnostic events from simulation results.
- If
event_auth_checkedcontainsblocked, maps the contract reason code (e.g.PerTxCapExceeded,AdminFrozen) into a human-readableGuardBlockedError. - If simulation succeeds, returns an
AdmissibleDecisionwith estimated inclusion and resource fees.
💰 CostPreChecker
Computes transaction execution cost prior to broadcast:
- Reads
minResourceFeeand storage footprint size. - Calculates footprint bump fees required for custom account
__check_authstorage reads. - Asserts resource total against optional operator fee ceilings (
maxResourceFeeStroops).
📡 GuardTelemetryListener
Tails guard events using getEvents():
- Extracts uncommitted diagnostic events (refusals) and committed ledger events (
initialized,policy_set,frozen,unfrozen). - Normalizes topics and parses ScVal payloads into TypeScript
GuardEventpages.
