Wrap your Ampersend X402Treasurer with automatic US sales tax calculation across all 50 states. Runs async — never touches your payment flow. Every settled transaction gets a tax calculation and audit trail.
$ npm install @agenttax/ampersendWrap your existing Treasurer. Everything else stays the same.
import { createAmpersendTreasurer } from "ampersend-sdk";
import { withTaxCompliance } from "@agenttax/ampersend";
// Your existing Ampersend setup
const treasurer = createAmpersendTreasurer({
wallet: myWallet,
apiKey: process.env.AMPERSEND_SESSION_KEY,
});
// Wrap it — one line
const taxTreasurer = withTaxCompliance(treasurer, {
apiKey: "atx_live_...", // Free at agenttax.io — 100 calls/mo
defaultBuyerState: "TX", // Buyer's US state
transactionType: "compute", // compute, saas, api_access, consulting, etc.
});
// Use taxTreasurer exactly like your original treasurer.
// Tax is calculated async on every accepted payment — never blocks.Aggregate all tax calculations for reporting.
// After some transactions...
const summary = taxTreasurer.getTaxSummary();
console.log(summary);
// {
// transactions: 47,
// totalAmount: 125.50,
// totalTax: 6.28,
// effectiveRate: 0.05,
// byState: { TX: 4.50, CA: 0, NY: 1.78 }
// }Get notified on every tax calculation with full jurisdiction details and statute citations.
const taxTreasurer = withTaxCompliance(treasurer, {
apiKey: "atx_live_...",
defaultBuyerState: "TX",
transactionType: "compute",
onTaxCalculated: (entry) => {
console.log(`Payment ${entry.authorizationId}: ${entry.amount}`);
console.log(` Tax: ${entry.tax.total_tax} (${entry.tax.sales_tax?.jurisdiction})`);
console.log(` Rate: ${(entry.tax.sales_tax?.rate * 100).toFixed(2)}%`);
console.log(` Note: ${entry.tax.sales_tax?.note}`);
// → Payment abc123: $5.00
// → Tax: $0.25 (Texas)
// → Rate: 6.25%
// → Note: TX Tax Code §151.351 — 20% statutory exemption
},
});Not using X402Treasurer? Use the standalone calculator for batch or retroactive tax on existing payments.
import { createTaxCalculator } from "@agenttax/ampersend";
const tax = createTaxCalculator({
apiKey: "atx_live_...",
defaultBuyerState: "NY",
transactionType: "api_access",
});
// Calculate tax for any transaction
const result = await tax.calculate({ amount: 100.00 });
console.log(result.total_tax); // 4.00 (NY 4% state rate)
// Batch — retroactive calculation on existing payments
for (const payment of ampersendPaymentHistory) {
await tax.calculate({
amount: payment.amountUsd,
buyerState: payment.buyerState,
counterpartyId: payment.sellerId,
});
}
console.log(tax.getTaxSummary());Prefer zero dependencies? Call the API directly.
// Direct REST — no SDK needed
const response = await fetch('https://agenttax.io/api/v1/calculate', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.AGENTTAX_API_KEY,
},
body: JSON.stringify({
role: 'seller',
amount: 1250.00,
buyer_state: 'WA',
transaction_type: 'saas',
counterparty_id: 'amp_buyer_77a3f',
is_b2b: false,
}),
});
const tax = await response.json();
// { taxable: true, total_tax: 87.50, combined_rate: 0.07, ... }Free tier — 100 calls/month, no credit card. One line to add, runs async.
© 2026 Agentic Tax Solutions LLC. Tax rates verified daily against Tax Foundation, Sales Tax Institute, state DOR websites, Anrok, TaxJar, TaxCloud, and Kintsugi. AgentTax provides tax calculations for informational purposes only. Consult a qualified tax professional for compliance decisions.