Skip to main content
AgentTax
Integration · PayAI Network

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 — so when you file, the 1099-DA data is already structured and your state DOR exposure is known.

How it works

01
Get your API key
Sign up at agenttax.io — free tier, no credit card. You get 100 calls/month and an API key in under 60 seconds.
02
Record every settled PayAI transaction
In the paid route handler (runs after successful x402 settlement), POST the amount and buyer state to AgentTax. You get back a transaction_id, the tax breakdown by jurisdiction, and a confidence score — instant 1099-DA-ready record.
03
Remit tax from gross, file clean
You've collected full payment via PayAI's facilitator. AgentTax has the obligation logged per-state. When you file, the data is already structured for your accountant or the state DOR — no reconstruction from chain data.

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.001",
        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.001,
      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" } });
  }
});

Example response

{
  "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

Base
EVM L2, USDC
Polygon
EVM L2, USDC
Avalanche
EVM L1, USDC
Sei
EVM L1, USDC
X Layer
EVM L2, USDC
Solana
PayAI flagship, SVM

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.