Payment policies
Examples of configuring payment limits and restrictions.
Basic Policy Configuration
import { createAgent } from '@regent/core';
import { http } from '@regent/http';
import { payments } from '@regent/x402';
import { createAgentApp } from '@regent/hono';
const agent = await createAgent({
name: 'policy-agent',
version: '1.0.0',
})
.use(http())
.use(payments({
config: {
payTo: '0x1234567890123456789012345678901234567890',
facilitatorUrl: 'https://facilitator.example.com',
network: 'base-sepolia',
policyGroups: [
{
name: 'daily-limits',
outgoingLimits: {
global: {
maxPaymentUsd: 10, // Max $10 per payment
maxTotalUsd: 100, // Max $100 per day
windowMs: 24 * 60 * 60 * 1000,
},
},
},
],
},
}))
.build();
const { app } = await createAgentApp(agent);Outgoing Limits
Limit payments your agent makes to other agents:
Incoming Limits
Limit payments your agent accepts:
Recipient Whitelists/Blacklists
Control who your agent can pay:
Sender Whitelists/Blacklists
Control who can pay your agent:
Rate Limiting
Limit the number of payments in a time window:
Multiple Policy Groups
Combine multiple policies (all must pass):
Loading Policies from File
Create payment-policies.json:
Load in your agent:
Storage Configuration
Configure where payment tracking data is stored:
Complete Example
Last updated