Work through this page when your service runs on TestNet and you are ready to take real money. On MainNet, payments move real ALGO and USDC.

What changes

Go-live checklist

1

Separate the accounts

Use a receiving account (pay_to) where revenue collects, and a separate fee payer account holding only the ALGO needed for fees. In PaymentGate the fee payer is the signer’s account; pay_to can be any address.
2

Opt in to USDC

If you price in USDC, opt pay_to in to asset 31566704; every buyer must opt in too. See Accept USDC.
3

Fund the fee payer

Enough ALGO for the calls you expect plus its minimum balance, with an alert. See Fund the fee payer.
4

Load keys from a secret store

Never put private keys or mnemonics in source code or images. See Keys.
5

Share the replay store across workers

With more than one worker process, pass replay_db="/var/lib/<service>/replay.db". See Replay store.
6

Use reliable nodes

The public AlgoNode endpoints need no key. For production traffic, consider your own node or a provider with an SLA, and point the SDKs at it.
7

Keep the clock in sync

Run NTP on servers that rely on passes, subscriptions or per-caller prices: identity proofs are accepted only within 120 seconds of the server’s clock.
8

Simulate before you go live

Check ALGO and USDC payment groups against MainNet without keys or funds. See Simulate on MainNet.
9

Monitor

Fee payer balance, settlement failures, replay rejections. See Monitor.

Server configuration

server_mainnet.py
Run it with several workers, for example uvicorn server_mainnet:app --workers 4. On the client side, paid_mcp_session(server_url, buyer_sk, "mainnet") uses the public MainNet algod unless you pass algod_url. Its default spend controls allow ALGO and MainNet USDC up to 1,000,000 base units per payment. Keep a buyer’s balance small: the cap does not limit how many payments a session makes.

Accept USDC

usdc_asset_id(network) (Python) and MAINNET.usdc / TESTNET.usdc (JavaScript) return these ids. Prices are integers in base units: Opt in. An Algorand account only holds assets it has opted in to, which stops unwanted assets being sent to it. Both the vendor’s pay_to account and every buyer need a 0-amount transfer of the asset to themselves:
Each opt-in raises the account’s minimum balance by 0.1 ALGO, so the account needs that ALGO first. If either side has not opted in, the facilitator’s simulation fails with transaction_simulation_failed, and the node’s message in invalid_message names the account. Fees stay in ALGO. The buyer spends only USDC; the fee payer spends 2,000 microALGO per call (why). The fee floor does not apply to USDC prices. For an HTTP API with x402-algorand, put the asset in the route price: {"amount": "50000", "asset": "31566704"}. Clients allow MainNet and TestNet USDC by default, up to 1 USDC per payment. Buyers with higher prices raise the cap, for example spend_controls={"max_amount_per_payment": "$5"}. On TestNet, use asset 10458941 and get test USDC from Circle’s faucet at faucet.circle.com:

Fund the fee payer

The fee payer pays 2,000 microALGO per settled call, whatever asset the price is in: Add its 0.1 ALGO minimum balance, alert when the balance falls below a threshold (for example 5 ALGO), and top it up from a treasury account. When it runs out, settlement fails and callers get SettlementError("payment settlement failed: ..."): they are not charged, but they get no result either.

Keys

Load keys at start-up from the environment or a secret manager:
DefaultAvmSigner keeps the key in process memory and signs only the fee payer transaction of each group. Since 0.5.0 the key is not in a public attribute and repr() shows only the address; DefaultAvmSigner.private_key is read-only and deprecated, so keep your own reference if you need the key. Hold only working capital in the fee payer.

One configuration for every network

shared/config.py builds the endpoints, network id and payment asset from one NETWORK variable (localnet, testnet or mainnet): ALGO on LocalNet, USDC on TestNet and MainNet. It reads NETWORK, ALGOD_URL, ALGOD_TOKEN, INDEXER_URL and INDEXER_TOKEN.
shared/config.py
Source: examples/shared/config.py python shared/config.py --dry-run prints the configuration of all three networks without sending a transaction (it reads LocalNet’s genesis hash from its algod):
Then set the environment for production. VENDOR_ADDRESS and FEE_PAYER_MNEMONIC are read by your own server code, as in Server configuration:

Simulate on MainNet

mainnet/simulate.py and mainnet/simulate.mjs are the TestNet simulations with MainNet settings: they find funded accounts through the public MainNet indexer, build ALGO and USDC (31566704) groups with and without a fee payer, and check them with algod’s simulate endpoint. Nothing is signed with a funded key and nothing is sent.

Monitor

The ai_economy_sdk logger records refused calls, settlement failures, expired reservations and failed chain lookups at WARNING; x402_algorand logs fee payer signing, simulation and settlement failures. Attach a handler, for example logging.basicConfig(level=logging.WARNING), and alert on them.