Stellar Hacks: Agents 2026

Revenue-Based
Auto-Repayment
on Stellar

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.

View Source Learn More
How It Works

From Payment to Repayment in One Transaction

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.

1

Agent Requests Paid API

An AI agent calls /api/research. Server returns HTTP 402 with MPP payment challenge.

2

Agent Pays with USDC on Stellar

Agent pays 0.01 USDC via MPP (Machine Payments Protocol). Transaction settles in ~5 seconds on Stellar. Fee: ~$0.00001.

3

AutoRepay Splits Payment On-Chain

The receive_payment function atomically splits the revenue: 30% to lender (repayment), 70% to borrower (surplus). Configurable via repay_bps.

4

Loan Auto-Completes

When total repaid ≥ principal + interest, loan status flips to Repaid. No manual intervention, no cron jobs.

Why Stellar

Programmable Stablecoins, Not Just Transfers

Most stablecoins are just digital IOUs — you send and receive them. Stellar's Soroban makes USDC programmable. AutoRepay demonstrates what that means in practice.

Atomic Revenue Splitting

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.

🔧

Configurable Logic On-Chain

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.

🤖

Agent-Native Payments

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.

💰

$0.00001 Fees

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.

What "Programmable" Actually Means

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:

// Soroban contract — receive_payment function // This runs ON-CHAIN as part of the USDC transfer // 1. Calculate what's owed let total_owed = principal * (10000 + interest_bps) / 10000; let remaining = total_owed - loan.repaid; // 2. Split the payment based on configurable ratio let repay_amount = amount * vault.repay_bps / 10000; let actual_repay = min(repay_amount, remaining); // 3. Atomically transfer to lender token_client.transfer(&contract, &loan.lender, &actual_repay); // 4. Send surplus to borrower token_client.transfer(&contract, &vault_owner, &surplus); // 5. Auto-complete loan when fully repaid if loan.repaid >= total_owed { loan.status = LoanStatus::Repaid; }

This is a single atomic transaction. Either all transfers succeed or none do. No race conditions, no partial states, no reconciliation needed.

CapabilityTraditional RailsStellar + Soroban
Revenue SplitBackend cron + DB trackingAtomic on-chain
Loan StateSQL databaseContract storage
Auto-CompleteManual check + webhookIn-transaction
MicropaymentsNot viable (fees > payment)$0.00001/tx
Agent PaymentsAPI key + billing cycleHTTP 402 + MPP
Trust ModelTrust the backend operatorVerify on-chain
Architecture

System Overview

┌─────────────────┐ HTTP 402 ┌──────────────────────┐ │ AI Agent │◄────────────────►│ API Server │ │ │ MPP Payment │ (Borrower) │ │ "I need data" │ │ │ │ "Here's USDC" │ │ Revenue Vault │ └─────────────────┘ │ repay_bps: 3000 │ └──────────┬───────────┘ │ ┌──────────────────┼──────────────────┐ │ │ │ ▼ ▼ │ ┌─────────────────┐ ┌───────────────┐ │ │ AutoRepay │ │ USDC (SAC) │ │ │ Contract │ │ on Stellar │ │ │ │ │ │ │ │ Loan State │ │ Atomic split: │ │ │ Vault Config │ │ 30% → Lender │ │ │ Repay Logic │ │ 70% → Borrower│ │ └─────────────────┘ └───────────────┘ │ │ │ ▼ │ ┌─────────────────┐ │ │ Lender │◄───────── repayment ───────┘ │ │ │ Gets auto- │ │ repaid from │ │ every API call │ └─────────────────┘
Tech Stack

Built With

ComponentTechnologyPurpose
Smart ContractSoroban (Rust)Loan management, revenue splitting, auto-repayment
StablecoinUSDC (Stellar Asset Contract)Payment currency — programmable via Soroban
Payment ProtocolMPP (@stellar/mpp)HTTP 402 micropayments for agent-to-server transactions
Demo ServerHono + TypeScriptPaid API with MPP middleware
NetworkStellar Testnet~5s finality, $0.00001 fees

Contract Functions

FunctionDescription
create_loanBorrower creates a loan request specifying lender, principal, and interest rate
fund_loanLender funds the loan — principal transferred to borrower via contract
create_vaultBorrower sets up a revenue vault with configurable repay ratio (repay_bps)
receive_paymentCore function — atomically splits incoming revenue between lender and borrower
get_loanQuery loan state (principal, repaid, status)
get_vaultQuery vault state (total received, total repaid, repay ratio)
Use Cases

Who Benefits

🤖

AI Agent Operators

Borrow to deploy an agent, set up a revenue vault, and let the agent's earnings automatically repay the loan. No manual accounting.

🏦

DeFi Lenders

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.

🔌

API Providers

Accept micropayments from AI agents via MPP. No subscription management, no invoicing — machines pay per request in USDC.