Tax compliance for PayAI Network merchants
PayAI settles x402 payments for 1,000+ merchants across Base, Polygon, Avalanche, Sei, X Layer, and Solana. Every one of those transactions is a taxable event in the US. AgentTax is the drop-in layer that records tax obligations per-jurisdiction on every settlement.
One fetch in your route handler after settlement. 51 US state-level jurisdictions plus 100+ zip-level local rates, with statute citations and confidence scores on every record.
3-step integration
The handler
PayAI's @x402/express middleware handles settlement. Your route handler records the tax obligation to AgentTax right after. One fetch, one transaction_id returned, logged per-jurisdiction.
// PayAI x402 merchant — record each settled transaction to AgentTax.
// Drops into the route handler that runs AFTER successful x402 settlement.
import express from "express";
import { paymentMiddleware, x402ResourceServer } from "@x402/express";
import { ExactEvmScheme } from "@x402/evm/exact/server";
import { HTTPFacilitatorClient } from "@x402/core/server";
import { facilitator } from "@payai/facilitator";
const app = express();
const facilitatorClient = new HTTPFacilitatorClient(facilitator);
app.use(paymentMiddleware(
{
"GET /weather": {
accepts: [{
scheme: "exact", price: "$0.005",
network: "eip155:8453", payTo: process.env.EVM_ADDRESS,
}],
description: "Weather data",
mimeType: "application/json",
},
},
new x402ResourceServer(facilitatorClient)
.register("eip155:8453", new ExactEvmScheme()),
));
async function recordTax({ amount, buyerState, counterpartyId }) {
const res = await fetch("https://agenttax.io/api/v1/calculate", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${process.env.AGENTTAX_API_KEY}`,
},
body: JSON.stringify({
role: "seller",
amount,
buyer_state: buyerState,
transaction_type: "compute",
counterparty_id: counterpartyId,
}),
});
if (!res.ok) throw new Error(`AgentTax ${res.status}`);
return res.json();
}
app.get("/weather", async (req, res) => {
const buyerState = req.query.buyer_state || process.env.AGENTTAX_DEFAULT_STATE;
try {
const tax = await recordTax({
amount: 0.005,
buyerState,
counterpartyId: req.header("x-payer-address") || "anonymous",
});
res.json({
weather: "sunny", temperature: 70,
agenttax: {
transaction_id: tax.transaction_id,
tax_amount: tax.sales_tax?.amount,
tax_rate: tax.sales_tax?.combined_rate,
jurisdiction: tax.sales_tax?.buyer_state,
},
});
} catch {
// Payment already settled — surface the error but don't fail the request.
res.json({ weather: "sunny", temperature: 70, agenttax: { error: "record_failed" } });
}
});Response shape
{
"success": true,
"sales_tax": {
"taxable": true,
"amount": 0.0063,
"state_tax": 0.0063,
"local_tax": 0,
"combined_rate": 0.0625,
"buyer_state": "TX",
"classification_basis": "digital_service",
"advisories": [
"TX §151.351: 80% of digital services taxable (20% statutory exemption)"
]
},
"confidence": { "score": 95, "level": "high" },
"transaction_id": "txn_payai_abc123"
}Supported networks
New to x402 in general? See the generic x402 integration guide.
Ship tax-compliant PayAI merchants today
Clone the starter repo, drop in your AgentTax API key, and run it. 100 calls/month free — no credit card.