________ ________ ___ ___ ________ _______ ________ _________
|\ __ \|\ __ \ |\ \ / /||\ ____\|\ ___ \ |\ ___ \|\___ ___\
\ \ \|\ \ \ \|\ \ \ \ \/ / /\ \ \___|\ \ __/|\ \ \\ \ \|___ \ \_|
\ \ ____\ \ __ \ \ \ / / \ \ \ __\ \ \_|/_\ \ \\ \ \ \ \ \
\ \ \___|\ \ \ \ \ \/ / / \ \ \|\ \ \ \_|\ \ \ \\ \ \ \ \ \
\ \__\ \ \__\ \__\__/ / / \ \_______\ \_______\ \__\\ \__\ \ \__\
\|__| \|__|\|__|\___/ / \|_______|\|_______|\|__| \|__| \|__|
\|___|/
Trustless machine-to-machine payments for AI agents
Stacks / Bitcoin L2. Clarity Smart Contracts
agentpay-demo
> FOR DEVELOPERS
Add pay-per-request sBTC payments to any Stacks API in 3 lines.
server.ts
import { x402Paywall } from "agentpay/x402";
app.post("/api/data", x402Paywall({
price: 50,
tokenSymbol: "sBTC",
payTo: "SP...your-address",
network: "stacks-mainnet",
}), yourHandler);
client.ts
import { x402Fetch } from "agentpay/x402";
// Handles 402 automatically: pays, retries, returns data
const result = await x402Fetch("https://api.example.com/data");
Settlement
Clarity smart contract (on-chain secp256k1 verification)
Tokens
Any SIP-010: sBTC, USDCx, or custom
Mainnet
Change one env var: TOKEN_CONTRACT_ADDRESS=SM3VDX...sbtc-token
Escrow
Funds locked until delivery is cryptographically proven
Refund
Automatic after 144 blocks (~24h) if provider never delivers