# Rail adapters

The five-method contract every rail adapter keeps, how Abazi picks a network in a fixed order, and how x402 facilitator health and failover work.

<ShortProductTruth>**One tool call. Every rail.** A rail adapter is the only part of Abazi that knows how a particular way of paying works. Everything before it and after it is the same for every rail.</ShortProductTruth>

## Switch the rail [#switch-the-rail]

<RailSwitcher />

Each rail has one adapter. Together they cover these rails, networks and assets:

<RailMatrix />

Per-rail settlement, receipts and custody are on [Supported rails](/docs/platform/supported-rails).

## The adapter contract [#the-adapter-contract]

Every adapter offers the same five methods. The core calls them in this order and never needs to know which rail it is talking to.

| Method | What it does |
| --- | --- |
| Quote | Asks the merchant what it would cost. For x402 this reads the 402 response and its payment options; the result also says when a resource is free or cannot be paid. |
| Authorize | Runs the signer's recheck (pause switch, mandate, reservation, fingerprint) and, only if it passes, produces the signed payment. This is the only place signing happens. |
| Execute | Sends the signed payment on its rail and reports one of three outcomes: submitted, failed before anything was sent, or unknown. |
| Confirm | Reads the network or processor and reports finalized, pending, failed or not found, with the amount, payee and asset it observed. |
| Refund | Returns money for a confirmed payment, from the merchant, or as a card return. |

Adapters never commit to the database themselves. The workflow around them records each step, so a restart after signing goes to reconciliation instead of signing again.

## Network selection [#network-selection]

A merchant's 402 response can offer several networks. Abazi picks one in a fixed order:

1. Keep only the networks the mandate allows.
2. Sort them by the priority order: Solana, Base, Polygon, Avalanche, Ethereum, Tron. A mandate can set its own order.
3. Take the first network that is funded for this payment (a delegation with enough room on Solana, a spending wallet with enough balance elsewhere) and, for x402, has a healthy facilitator.

If no allowed network qualifies, the policy denies at step 4b with <ReasonCode code="NO_FUNDED_CHAIN" />, or with <ReasonCode code="DELEGATION_MISSING" /> when only Solana was possible and the owner has not granted the delegation. The decision trace lists every candidate network and why it was or was not used.

## Facilitator health and failover [#facilitator-health-and-failover]

x402 payments are settled through a facilitator. Abazi keeps an ordered list of facilitators for each network and:

- probes each one's list of supported networks on a schedule and records whether it answered and covered the network;
- opens a circuit breaker on a facilitator after 3 consecutive failures and skips it for 60 seconds;
- treats a network as healthy while at least one facilitator for it is not skipped and last answered well;
- fails over to the next facilitator only when the first could not be reached at all, so nothing was sent.

A settlement that may have been sent is never sent again to another facilitator. The payment goes to reconciling instead.

## Example [#example]

An agent buys a service whose 402 response offers Base and Solana. The mandate allows both. Solana comes first in the order, but the owner has not granted the delegation, so Abazi uses Base from the agent's spending wallet. The trace shows Solana as not funded and Base as chosen.

## Failure cases [#failure-cases]

| Situation | What happens |
| --- | --- |
| Every facilitator for the chosen network is down | The network is unhealthy; the next allowed, funded network is used, or the purchase is denied with <ReasonCode code="NO_FUNDED_CHAIN" />. |
| The merchant's 402 asks for a different payout address than the Catalog lists | Denied at step 2 with <ReasonCode code="PAYTO_MISMATCH" />. |
| The rail answers with an error before sending | The payment fails and the reservation is released. |
| The rail times out after sending | The payment goes to reconciling and the money stays held. |

## Next steps [#next-steps]

<Cards>
  <Card title="Rails and networks" href="/docs/concepts/rails-and-networks" description="Why one mandate spans every rail, and how a network is chosen." />
  <Card title="Accept agent payments" href="/docs/guides/accept-agent-payments" description="See the 402 exchange from the merchant's side." />
  <Card title="Pay with a virtual card" href="/docs/guides/pay-with-a-virtual-card" description="Follow a card authorization through the same policy." />
</Cards>

