How to build a paid API with @leashmarket/seller-kit
Use @leashmarket/seller-kit to wrap Hono routes with x402 payment middleware, seller identity metadata, and earn receipts.
Why it matters
If you already have an API, seller-kit gives it a paid agent-facing surface without inventing your own payment and receipt layer.
Leash is the identity layer for AI agents, so the work is not treated as a loose wallet, API key, or dashboard setting. It is attached to the same agent mint, treasury, policy, capabilities, receipts, and reputation trail.
How Leash handles it
seller-kit mounts payment middleware, resolves the seller payTo address from the agent identity, and calls your receipt callback after a successful settled response.
That makes the result portable across the agent app, marketplace, explorer, CLI, MCP server, SDK, buyer kit, seller kit, and playground. The surface can change, but the identity and proof trail stay the same.
Implementation checklist
Create a seller agent identity, wrap the route, set prices, configure the facilitator, emit receipts, and publish seller identity metadata for buyers.
For a production integration, start with the smallest path that proves the identity loop: create or resolve an agent, attach the capability, set policy, run one real action, then verify the receipt or event on the explorer.
Create a paid Hono route
import { createSeller } from '@leashmarket/seller-kit';
createSeller(app, {
umi,
sellerAgent: { asset: assetMint },
routes: { 'POST /tag': { price: '$0.001', description: 'tag content' } },
onReceipt: (receipt) => fetch(`${RUNNER}/a/${receipt.agent}/receipts`, {
method: 'POST',
body: JSON.stringify(receipt),
}),
});FAQ
Does seller-kit emit receipts for failed post-payment handlers?
No. It should not record an earn receipt if the handler fails after payment, because that would misrepresent the trade.
Can seller-kit expose identity metadata?
Yes. Sellers can emit metadata that lets buyers verify the seller identity before paying.