# TaxRail — Autonomous Tax-Optimization Rail for AI Agents (US + Brazil) > TaxRail calculates verified tax savings for crypto disposals, DeFi Aave v3 borrow-vs-sell liquidity, and business expenses across US (IRS Individual, LLC, C-Corp) and Brazil (Lei 14.754/2023, PF Domestic R$35k, PJ Lucro Real, Simples Export). ## $0-Upfront 1-Click Flow (Pay 10% From Operation Proceeds) 1. **Step 1 — FREE Preview (No Payment Required)** - Call POST https://api.taxrail.online/api/v1/check-tax-impact, POST https://api.taxrail.online/api/v1/borrow-vs-sell, or POST https://api.taxrail.online/api/v1/classify-expense (or MCP tools `check_tax_impact`, `compare_borrow_vs_sell`, `classify_deductible_expense`). - Receive exact `baselineTaxUsd`, `optimizedTaxUsd`, `taxSavedUsd`, dynamic `pricing` quote, and a `planId` (TTL: 15 minutes). - Sensitive execution details (exact `lotId`s and accounting exports) are redacted until fee verification. 2. **Step 2A — $0-Upfront 1-Click Execution (Recommended for Swaps & Aave v3 Borrow)** - Call POST https://api.taxrail.online/api/v1/prepare-execution (or MCP tool `prepare_execution`) with `{ "planId": "...", "takerAddress": "0x..." }` for **$0 upfront**. - Returns ready-to-sign `0x v2` / `Jupiter` swap calldata (up to 1000 bps / 10%) or `Aave v3` `atomicBatchCalls` (borrowing `liquidityNeeded + 10% fee` and transferring the fee from the borrowed USDC). - Broadcast the transaction, then call POST https://api.taxrail.online/api/v1/claim-dossier (or MCP tool `claim_dossier`) with `{ "planId": "...", "txHash": "0x...", "chain": "base" }` to verify the on-chain fee transfer and unlock `selectedLots` + `accountingDossier`. 3. **Step 2B — Dossier-Only Fallback via x402 v2 (Base USDC)** - Call POST https://api.taxrail.online/api/v1/unlock-plan with `{ "planId": "..." }` (or MCP tool `unlock_tax_plan`). - If `pricing.upfrontX402Usd == 0` (e.g., $0 verified tax savings), the plan unlocks immediately for FREE. - Otherwise, the worker responds with **HTTP 402 Payment Required** and a `PAYMENT-REQUIRED` header for Base USDC (`eip155:8453`) equal to **10% of verified tax savings** (upfront guardrail for dossier-only / corporate expense unlocks). - Retry with `X-PAYMENT` or `PAYMENT-SIGNATURE` header to receive `selectedLots`, calldata, and `accountingDossier`. ## Example ROI - Disposal of $50,000 ETH with mixed short-term and long-term lots: - Baseline FIFO tax: **$9,600** - TaxRail HIFO + Tax-Loss Harvesting tax: **$2,100** - Verified Tax Saved: **$7,500** - TaxRail Fee (10%): **$750 total** (**$0 upfront** — 150 bps embedded inside the swap output) - Client Net Benefit: **$6,750** (**10x ROI**) ## Affiliate RevShare (20%) Pass `referrerWallet` (e.g., `"0xYourAgentWallet"`) in any Step 1 request to earn **20% of TaxRail's total fee** automatically. ## Endpoints & Specs - **Portable Agent Skill (`SKILL.md`):** https://api.taxrail.online/SKILL.md - **MCP Streamable HTTP:** https://api.taxrail.online/mcp (`npx -y taxrail-mcp`) - **TypeScript Agent SDK:** `npm install taxrail-agent-tools` - **Python Agent SDK (Zero-Deps + LangChain/CrewAI):** `pip install taxrail` - **A2A Agent Card:** https://api.taxrail.online/.well-known/agent.json - **x402 Discovery Manifest:** https://api.taxrail.online/.well-known/x402 - **OpenAPI 3.1 Spec:** https://api.taxrail.online/openapi.json - **$0.01 Wallet TLH Scanner (1-param GET):** https://api.taxrail.online/api/v1/x402/tlh-scan?walletAddress=0x...&chain=base - **Pre-Trade Swap / Sell Guardrail ($0.01 USDC):** https://api.taxrail.online/api/v1/x402/pre-trade-check?walletAddress=0x...&sellAsset=ETH&sellAmount=1 - **Prepare $0-Upfront 1-Click Execution (FREE):** https://api.taxrail.online/api/v1/prepare-execution - **Claim Dossier After On-Chain Execution:** https://api.taxrail.online/api/v1/claim-dossier - **$0.005 Brazil R$35k & Lei 14.754 Check:** https://api.taxrail.online/api/v1/x402/br-35k-status?monthlySalesBrl=20000&plannedSaleUsd=2500&custodyLocation=DOMESTIC - **1-Step Paid Optimize ($0.10 USDC):** https://api.taxrail.online/api/v1/x402/optimize - **Agent Feedback (FREE):** https://api.taxrail.online/api/v1/feedback - **Verified Reputation (FREE):** https://api.taxrail.online/api/v1/reputation - **Health Check:** https://api.taxrail.online/health ## Copy-Paste Agent Quickstart ```bash # $0.01 instant multi-asset wallet TLH & tax-risk scan (x402 Base USDC) curl -i "https://api.taxrail.online/api/v1/x402/tlh-scan?walletAddress=0x849151d7D0bF1F34b70d5caD5149D28CC2308bf1&chain=base&asset=ALL" # $0.01 pre-trade swap/sell guardrail check (HIFO vs FIFO, ST->LT cliff, Aave borrow-vs-sell) curl -i "https://api.taxrail.online/api/v1/x402/pre-trade-check?walletAddress=0x849151d7D0bF1F34b70d5caD5149D28CC2308bf1&sellAsset=ETH&sellAmount=1&chain=base" # $0.005 Brazil R$35k monthly exemption & Lei 14.754 compliance check curl -i "https://api.taxrail.online/api/v1/x402/br-35k-status?monthlySalesBrl=20000&plannedSaleUsd=2500&custodyLocation=DOMESTIC" # FREE tax-impact preview -> get planId & exact ROI quote curl -X POST "https://api.taxrail.online/api/v1/check-tax-impact" -H "Content-Type: application/json" \ -d '{"jurisdiction":"US","regime":"INDIVIDUAL","chain":"base","targetAsset":"ETH","sellQuantity":1,"walletAddress":"0x849151d7D0bF1F34b70d5caD5149D28CC2308bf1"}' ```