AI agents earn revenue through paid APIs. AutoRepay automatically splits every payment — a portion goes to loan repayment, the rest to the borrower. All on-chain, all programmable.
AutoRepay uses Soroban smart contracts to intercept revenue at the source. When an AI agent pays for an API, the payment is split atomically — lender gets repaid, borrower keeps the surplus.
An AI agent calls /api/research. Server returns HTTP 402 with MPP payment challenge.
Agent pays 0.01 USDC via MPP (Machine Payments Protocol). Transaction settles in ~5 seconds on Stellar. Fee: ~$0.00001.
The receive_payment function atomically splits the revenue: 30% to lender (repayment), 70% to borrower (surplus). Configurable via repay_bps.
When total repaid ≥ principal + interest, loan status flips to Repaid. No manual intervention, no cron jobs.
Most stablecoins are just digital IOUs — you send and receive them. Stellar's Soroban makes USDC programmable. AutoRepay demonstrates what that means in practice.
A single Soroban transaction receives a payment, calculates the repay portion, transfers to the lender, and sends surplus to the borrower. No intermediary, no batching, no delay.
repay_bps parameter (1-10000) controls the split ratio. Set 3000 = 30% auto-repaid. This logic lives in the contract, not in backend code. Trustless and auditable.
MPP (Machine Payments Protocol) enables HTTP 402 micropayments. AI agents pay per-request with USDC — no credit cards, no subscriptions, no human in the loop.
Stellar's transaction fees make micropayments viable. Ethereum gas would eat the entire payment. Stellar lets a $0.01 API call actually reach the recipient.
On a traditional payment rail (Stripe, PayPal, bank transfer), money goes from A to B. Period. To split revenue, you need a backend process, a cron job, and a database to track state.
On Soroban, the stablecoin itself understands your business logic:
This is a single atomic transaction. Either all transfers succeed or none do. No race conditions, no partial states, no reconciliation needed.
| Capability | Traditional Rails | Stellar + Soroban |
|---|---|---|
| Revenue Split | Backend cron + DB tracking | Atomic on-chain |
| Loan State | SQL database | Contract storage |
| Auto-Complete | Manual check + webhook | In-transaction |
| Micropayments | Not viable (fees > payment) | $0.00001/tx |
| Agent Payments | API key + billing cycle | HTTP 402 + MPP |
| Trust Model | Trust the backend operator | Verify on-chain |
| Component | Technology | Purpose |
|---|---|---|
| Smart Contract | Soroban (Rust) | Loan management, revenue splitting, auto-repayment |
| Stablecoin | USDC (Stellar Asset Contract) | Payment currency — programmable via Soroban |
| Payment Protocol | MPP (@stellar/mpp) | HTTP 402 micropayments for agent-to-server transactions |
| Demo Server | Hono + TypeScript | Paid API with MPP middleware |
| Network | Stellar Testnet | ~5s finality, $0.00001 fees |
| Function | Description |
|---|---|
create_loan | Borrower creates a loan request specifying lender, principal, and interest rate |
fund_loan | Lender funds the loan — principal transferred to borrower via contract |
create_vault | Borrower sets up a revenue vault with configurable repay ratio (repay_bps) |
receive_payment | Core function — atomically splits incoming revenue between lender and borrower |
get_loan | Query loan state (principal, repaid, status) |
get_vault | Query vault state (total received, total repaid, repay ratio) |
Borrow to deploy an agent, set up a revenue vault, and let the agent's earnings automatically repay the loan. No manual accounting.
Lend to agent operators with revenue-backed repayment. Every API call the agent serves sends a portion directly to you. Real yield from real usage.
Accept micropayments from AI agents via MPP. No subscription management, no invoicing — machines pay per request in USDC.