StellarMind uses a layered architecture where AI agents operate as autonomous services that charge for their work via the x402 payment protocol on Stellar.
User → Orchestrator (Claude plans tasks)
↓
Orchestrator → GET /api/premium/{agent}
↓
Server returns 402 Payment Required
↓
wrapFetchWithPayment (from @x402/fetch) auto-signs Stellar USDC tx
↓
Retries with X-PAYMENT header → Facilitator verifies → settles on-chain
↓
Server returns 200 + Claude response
-
x402 over custom payments: We use the official
@x402/expressmiddleware and@x402/fetchclient rather than building custom payment verification. This ensures compatibility with the x402 ecosystem. -
Budget enforcement in the orchestrator: The orchestrator checks
totalSpent + cost > budgetbefore each agent call. If exceeded, the agent is skipped. This demonstrates programmable spending policies. -
Dual payment mode: The system attempts x402 USDC payments first, then falls back to XLM direct transfers. Both produce real, verifiable on-chain transactions.
-
SSE for real-time updates: Server-Sent Events stream every orchestration event to the dashboard, giving users real-time visibility into agent activity and payments.
- Add the agent definition in
src/agents/registry.js - Add the service function in
src/agents/services.js - Add the premium endpoint in
src/server.js(both middleware config and route handler) - Map the agent ID to its endpoint in
src/agents/orchestrator.js
npm run demo # Runs 3 automated tasks with budget enforcement
npm test # Same as demo- Never commit
.envor generated wallet secrets. - Use placeholders only in
.env.example. - Before every push, run
git diff --stagedand verify no keys are present. - If a secret is exposed, rotate it immediately.
npm run setup # Generate Stellar wallets + fund via Friendbot
npm run setup:usdc # Add USDC trustlines for x402 payments
npm run dev # Start the serverBefore writing any code, comment on the issue you want to work on:
"I'd like to work on this — claiming it."
Wait for a maintainer to assign it to you. This prevents two people solving the same thing at once.
Fork the repo on GitHub, then clone your fork locally:
git clone https://github.com/YOUR_USERNAME/stellarmind.git
cd stellarmindAdd the original repo as upstream:
git remote add upstream https://github.com/Flamki/stellarmind.gitNever work directly on master. Name your branch after your issue:
docs/issue-44-contributor-workflow
fix/issue-12-short-description
feat/issue-27-short-description
git checkout -b feat/issue-27-short-descriptionKeep changes focused on the issue you claimed. Run locally to verify nothing breaks:
npm install
npm run devInclude Closes #<number> so GitHub auto-closes the issue on merge:
git commit -m "Your change description
Closes #44"git push origin your-branch-nameGo to your fork on GitHub, click "Compare & pull request", then fill in:
- Title: short description of what you did
- Description: what changed, how to test it, and
Closes #44