Trustlines
A Stellar account needs a trustline to a SEP-41 asset before it can hold that asset. The one people forget is the receiver’s: the seller’spayTo must trust the asset before it can be paid.
1
Fund the account
The account needs XLM to exist and to pay for its own trustline entry. The Rail402 CLI generates
and funds one from friendbot:Or fund an existing address in Stellar Lab directly.
2
Add the trustline
Add a trustline to the asset with a
changeTrust operation from any Stellar SDK, or build one in Stellar Lab.3
Get the asset
Get testnet USDC from the Circle faucet. XLM comes from friendbot.
See the error reference for the full set.
SEP-41 tokens and stroop math
Rail402 settles any SEP-41 token, with USDC as the default. SEP-41 is the Stellar token interface, and every SEP-41 asset is reachable from Soroban through its Stellar Asset Contract (SAC). The testnet USDC contract isCBIELTK6YBZJU5UP2WWQEUCYKLPU6AUNZ2BQ4WWFEIE3USCIHMXQDAMA.
Amounts are integers at 7 decimals, called stroops. One USDC is 10000000 atomic units, so 500000 is 0.05 USDC.
Fee sponsorship
The facilitator pays the Stellar network fee, so the buyer holds only the payment asset and needs no XLM. It does this by rebuilding the transaction with its own account as the source./supported advertises this with extra.areFeesSponsored: true, and the flag reflects real runtime configuration. You can confirm sponsorship on chain: for any settlement, the fee is charged to the facilitator, not the buyer.
Authorization entries
On Stellar the buyer signs a Soroban authorization entry, not a whole transaction. The entry permits one specific contract call (atransfer(from, to, amount) on the asset’s SAC) and nothing else. The facilitator builds and submits the transaction around it.
Each authorization is valid until a specific ledger, signatureExpirationLedger, roughly 12 ledgers (about 60 seconds) by default, derived from the seller’s maxTimeoutSeconds. After that ledger the authorization is dead and the buyer signs a new one. This is the mechanism behind both exact and upto.
Smart accounts
A buyer address can be either kind of Stellar account, and the facilitator settles from both:G keypair
A classic account controlled by an ed25519 keypair. It signs its own authorizations directly.
C contract account
A
__check_auth contract account (for example an OpenZeppelin smart account) with a session key and an on-ledger spending policy. Its policy can enforce a budget on the ledger itself.MAX_TRANSACTION_FEE_STROOPS accordingly (see Run the facilitator). A C-account spending policy is what upto composes with to keep an agent inside a budget.
Interop
None of the helpers are required to interoperate. A stock, unmodified@x402/* client pays a Rail402 endpoint with no Rail402-specific code, and reads the Bazaar through the same interface it uses for any facilitator. The helpers add ergonomics on top.
Next steps
The exact scheme
Auth entries and expiration in the fixed-price flow.
The upto scheme
Ceilings and smart-account spending policies.
The payment loop
The four roles and the full sequence.
Troubleshooting
Trustline and expiration failures, and their fixes.