Docs / Guides
Make an agent pay only bonded services
The buyer policy is checked against live on-chain data before every payment. If it fails, the SDK aborts the x402 payment: the seller never receives a request to serve and no transaction is made.
| Policy field | Meaning | Suggested starting point |
|---|---|---|
requireWarranty | Refuse sellers that offer no LOPW warranty at all | true (the default) |
minStake | Least stake the service must hold, in 7-decimal units | At least what a day of your calls could be worth in claims |
requiredPredicates | Predicate IDs the terms must include | [3] for data feeds, [6] for prices, [4, 5] for anything you pay per byte |
minMaxClaim | Least a single receipt must be able to pay out | At least the price of the call, usually more |
TypeScript
const agent = new LopwBuyer({
secret: process.env.AGENT_SECRET,
policy: { minStake: 100n * 10_000_000n, requiredPredicates: [6], minMaxClaim: 10_000_000n },
});
try {
const { warranty } = await agent.fetch(url);
} catch (e) {
// A policy refusal surfaces as an aborted x402 payment whose reason is the WarrantyRefused message,
// e.g. "stake below policy minimum", "service is Suspended", "warranty lacks predicate P6".
}Independently of the policy, the SDK only pays a service that is Active, under its current terms, with a valid, unexpired offer whose price and asset match the x402 requirements and which it has not paid before.
Watch the stake, not just the state
A service stays Active while stake is at or above its own min_stake, which may be as low as 100 USDC. If many agents could claim at once, later claims find less stake. minStake and minMaxClaim are how your agent prices that risk; the economics page works through it.