Anchor-Kit is designed to be the "Rails" for Stellar Anchors—opinionated but flexible, emphasizing convention over configuration.
- Type Safety First: Leveraging TypeScript to prevent runtime errors, especially for financial transactions.
- Plugin-Based: Core logic (server, auth, db connection) is separate from protocol implementations (SEPs) and payment rail integrations.
- Strict State Machines: Financial transactions follow rigid, unidirectional state transitions to prevent race conditions and double-spending.
- Developer Experience (DX): Inspired by tools like Better-Auth, providing a fluent, clear API.
createAnchor()andAnchorInstancelifecycle (use,init, plugin registry).AnchorConfigfor defaults, immutability, and validation.- Domain error hierarchy.
- Unified configuration interfaces.
- Transaction lifecycle and SEP-24 response typing.
- Foundation and plugin interfaces.
- Validation, decimal arithmetic, idempotency handling, crypto/JWT helpers, and Stellar helpers.
Modular implementations of SEPs and integrations.
sep24/: Hosted Deposit/Withdrawal flow.sep6/: API-based Transfer flow (Future).sep31/: Cross-border payments (Future).
Shared internal services.
StellarService: Wrappers around Horizon API.QueueService: Job queues for processing blockchain transactions asynchronously.
anchor-kit/
├── src/
│ ├── core/ # Factory, config, errors, planned protocol stubs
│ ├── services/ # Planned service layer (currently stubs)
│ ├── plugins/ # SEP implementations and Rail adapters
│ ├── utils/ # Runtime utilities
│ ├── types/ # Public type definitions
│ └── index.ts # Public API export
├── examples/ # implementing example servers
├── tests/ # Vitest test suite
└── dist/ # Compiled output
- Wallet initiates auth (SEP-10).
- Anchor-Kit verifies signature and issues JWT.
- Wallet requests deposit (SEP-24).
- Anchor-Kit creates transaction record (status:
incomplete) and returns interactive URL. - User completes KYC/Payment on the interactive page.
- Anchor-Kit receives Webhook from Payment Rail (e.g., Flutterwave).
- Anchor-Kit validates webhook, updates status to
pending_user_transfer_start. - Job Queue picks up job, sends Stellar Asset to user.
- Anchor-Kit updates status to
completed.