CrossFare

Cross-chain swap API for AI agents: no signup, pay per call on Hedera, every quote public on Arkiv

CrossFare

Created At

ETHGlobal Mumbai

Project Description

Crossfare is an open-source cross-chain swap API built for AI agents. Today an agent can plan a trade but can't execute one on its own: swap providers need a person to create an API key in a dashboard, and quotes are private promises nobody can check later.

With Crossfare, an agent with only a wallet can swap across chains with no signup. It pays 0.01 testnet USDC per quote over x402 on Hedera. Crossfare asks the SwapKit API (THORChain, Chainflip, NEAR Intents and more, across 30+ chains) and the Uniswap Trading API (same-chain swaps) for routes, and ranks them by guaranteed output. It publishes every route as a public entity on Arkiv, which expires with the quote. Before sending funds, the agent reads its quote back from Arkiv and checks the owner and numbers. After delivery, Crossfare records the amount actually received, so anyone can compare what was promised with what arrived.

Crossfare never holds the swapped funds: they go from the user's wallet to the provider and on to the receiver. Every settled payment is logged to a public Hedera Consensus Service topic, giving agent owners an audit trail of their agent's spending.

It's live. Through the reference agent, 2 USDC on Ethereum delivered 1.997376 USDC on Base. Through the web UI, with no wallet connected, 5 USDC on Ethereum delivered 0.0022257 ETH on Base. Payment, Arkiv record, deposit and delivery are all linked in the README.

How it's Made

TypeScript pnpm monorepo, no Solidity anywhere, 462 tests written test-first.

packages/core is the route engine: one adapter per venue (SwapKit API v3 for cross-chain, Uniswap Trading API for same-chain), normalized into one route shape and ranked by guaranteed minimum output. apps/api is a Hono service. Payments use the official x402 libraries (@x402/core and @x402/hedera, exact scheme) against the x402.org facilitator, with USDC as an HTS token on Hedera testnet. Our payment guard claims each payment first so replays fail, verifies it before calling any venue, and settles only when the request succeeds, so a failed quote costs the agent nothing. Settled payments are written to an HCS topic through the Hiero SDK.

Each route becomes an Arkiv entity owned by Crossfare's service wallet, with indexed attributes (project, venue, assets, status, timestamps) and a lifetime matching the quote. When the swap finishes, Crossfare writes the status and amount received and extends the record to 7 days. The reference agent (viem) has a per-call cap, a total budget and an allowlist of payTo accounts, and refuses any route it can't verify on Arkiv.

The web UI (React, Vite, wagmi) works like FixedFloat: no wallet needed, just a deposit address and QR code. Visitors have no Hedera account, so /demo endpoints pay the x402 fee from a rate-limited testnet account. UI on Vercel, API on AWS EC2.

Hacky bits: Arkiv lifetimes must be whole 2-second blocks, so we round up. Transaction hashes overflow Arkiv's 128-byte string limit, so we store them as bytes. SwapKit's status lags, so the API also reads the deposit address on chain every 4 seconds. Quote IDs are public on Arkiv, so executing a quote requires a private swap token that only the payer receives.

background image mobile

Join the mailing list

Get the latest news and updates

CrossFare | ETHGlobal