x402-reporter
v1.0.0
Published
x402 payment attribution reporter for AgentZone marketplace
Downloads
89
Maintainers
Readme
@agentzone/x402-reporter
Report x402 payments to AgentZone for attribution and reputation tracking
Installation
npm install @agentzone/x402-reporterUsage
Basic Reporting
import { reportPayment } from '@agentzone/x402-reporter';
await reportPayment({
agentId: 'your-agent-id',
txHash: '0xabc123...',
amount: 1.50,
from: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
chain: 'base',
});Global Configuration
import { configure } from '@agentzone/x402-reporter';
configure({
apiUrl: 'https://agentzone.vercel.app/api/v1/payments/report',
apiKey: 'your-api-key', // optional
timeout: 10000,
});Batch Reporting
import { reportBatch } from '@agentzone/x402-reporter';
const { success, results, errors } = await reportBatch([
{ agentId: 'agent-1', txHash: '0xabc...', amount: 1.0, from: '0x123...', chain: 'base' },
{ agentId: 'agent-2', txHash: '0xdef...', amount: 2.5, from: '0x456...', chain: 'base' },
]);Verify + Report
import { verifyAndReport } from '@agentzone/x402-reporter';
const result = await verifyAndReport(
{
agentId: 'your-agent-id',
txHash: '0xabc123...',
amount: 1.50,
from: '0x742d35...',
chain: 'base',
},
'https://mainnet.base.org' // RPC URL for verification
);Metadata
Include additional context:
await reportPayment({
agentId: 'oracle-xyz',
txHash: '0xabc...',
amount: 0.10,
from: '0x123...',
chain: 'base',
metadata: {
service: 'price-feed',
responseTime: 245,
success: true,
customField: 'value',
},
});API Reference
reportPayment(payment, config?)
Report a single payment.
Parameters:
payment: PaymentReport objectconfig?: Optional reporter config (overrides global)
Returns: Promise<{ success: boolean; error?: string }>
reportBatch(payments, config?)
Report multiple payments in parallel.
Returns: Promise<{ success: boolean; results: boolean[]; errors: (string | null)[] }>
verifyAndReport(payment, rpcUrl, config?)
Verify transaction on-chain before reporting.
Parameters:
payment: PaymentReport objectrpcUrl: RPC endpoint for verificationconfig?: Optional reporter config
configure(config)
Set global configuration.
Config Options:
apiUrl: AgentZone API endpoint (default:https://agentzone.vercel.app/api/v1/payments/report)apiKey: Optional API key for authenticationtimeout: Request timeout in ms (default: 10000)
TypeScript Types
interface PaymentReport {
agentId: string;
txHash: string;
amount: number; // USDC amount
from: string; // Payer address
chain: 'base' | 'arbitrum' | 'ethereum';
metadata?: {
service?: string;
responseTime?: number;
success?: boolean;
[key: string]: any;
};
}
interface ReporterConfig {
apiUrl?: string;
apiKey?: string;
timeout?: number;
}License
MIT © R69 Labs
