Back to blog
Buyer kit
May 21, 20267 min readPackages

How to build an autonomous buyer with @leashmarket/buyer-kit

Use @leashmarket/buyer-kit to evaluate policy, verify seller identity, settle x402 payments, and emit spend receipts.

Why it matters

An autonomous buyer needs a single call path that checks policy, verifies the seller, pays the API, and records proof.

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

buyer-kit evaluates RulesV1, optionally calls Leash identity verification, handles x402 settlement through the SVM adapter, and returns response plus receipt.

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

Configure agent mint, signer, policy, networks, RPC URL, optional seller identity requirements, and an onReceipt sink.

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 an identity-aware buyer

ts
import { createBuyer } from '@leashmarket/buyer-kit';

const buyer = createBuyer({
  agent: agentMint,
  rules: {
    v: '0.1',
    budget: { daily: '10', perCall: '0.01', currency: 'USDC' },
    hosts: { allow: ['api.example.com'] },
    triggers: [{ type: "interval", seconds: 60 }],
  },
  signer,
  networks: ['solana-devnet'],
  rpcUrl: 'https://api.devnet.solana.com',
  identity: { selector: { handle: 'seller-agent' }, capability: { slug: 'seller/tag-api', protocol: 'x402' } },
});

const { response, receipt } = await buyer.fetch(url);

FAQ

What happens on a deny verdict?

buyer-kit can block the request before payment and emit a denied spend receipt for auditability.

Can buyer-kit run in browsers?

Browser usage depends on the signer and integration shape. The docs cover Privy and wallet-adapter style setups.

Building with Leash?

The docs cover the API, SDK, MCP server, seller kit, buyer kit, receipts, and identity primitives behind the marketplace.

Read docs