@reapp-sdk/core · DOCS
Agent payments in 5 lines.
A user signs a budget-capped mandate; an AI agent pays under it; a Soroban contract enforces every limit on-chain. The SDK is untrusted — a buggy or malicious SDK can't exceed the mandate.
Install
npm install @reapp-sdk/core @stellar/stellar-sdkQuick start (testnet)
import { reapp } from "@reapp-sdk/core";
import { Keypair } from "@stellar/stellar-sdk";
const user = Keypair.fromSecret(USER_SECRET); // owns funds, signs the mandate
const agent = Keypair.fromSecret(AGENT_SECRET); // the autonomous spender
const m = reapp.createIntentMandate({
user: user.publicKey(),
agent: agent.publicKey(),
merchant: MERCHANT,
asset: reapp.testnet.nativeSac,
maxAmount: "5.00",
expiry: Math.floor(Date.now() / 1000) + 3600,
});
await reapp.registerMandate(m, { signer: user }); // authorize on-chain
await reapp.approveBudget(m, { signer: user }); // SEP-41 allowance -> contract
await reapp.agent({ mandate: m, signer: agent }).pay("1.00"); // agent-signedThat's the whole flow. pay() routes through MandateRegistry.execute_payment, which re-validates everything and moves funds atomically. Overspend, wrong merchant, replay, or pay-after-revoke → the contract rejects and pay() throws.
API
reapp.createIntentMandate(input)Build a mandate + its on-chain id (no chain call)reapp.registerMandate(m, { signer })Store it on-chain — user-signedreapp.approveBudget(m, { signer })Grant the contract a SEP-41 allowance — user-signedreapp.agent({ mandate, signer }).pay(amt)Execute a mandate-validated payment — agent-signedreapp.revokeMandate(m, { signer })Withdraw consent — user-signedErrorsTyped contract errors for branching (Errors[6] = BudgetExceeded)Why it's safe
- ✓ The allowance is granted to the CONTRACT, never the agent — funds stay in the user's wallet until the contract pulls them.
- ✓ execute_payment re-checks scope, budget, expiry, and replay against on-chain state on every spend.
- ✓ State is written before the transfer (checks-effects-interactions) — no reentrancy window.
- ✓ Independently audited (BulletproofBar, 0 confirmed defects) + 19 contract tests.