# x402-avm documentation > Pay-per-call MCP tools and HTTP APIs settled on Algorand with the x402 protocol: ai-economy-sdk, x402-algorand and x402-avm-js. Every page is also available as Markdown at its URL plus `.md`. The full text of all pages is at https://x402-avm.github.io/llms-full.txt. ## Documentation: Start here - [x402-avm](https://x402-avm.github.io/index.md): Let AI agents and apps pay for your tools and APIs per call, in ALGO or USDC, with no accounts and no API keys. - [Quickstart](https://x402-avm.github.io/quickstart.md): In about five minutes, run a paid MCP tool on a local Algorand network and pay for it from Python and from JavaScript. - [How it works](https://x402-avm.github.io/how-it-works.md): What happens between a 402 and a result: the payment flow, the two-transaction group, settle-on-success, replay protection, identity proofs and passes. ## Documentation: Build - [Sell MCP tools](https://x402-avm.github.io/build/sell-mcp-tools.md): Put a price on the tools of a FastMCP server, serve it, and confirm a paid call lands on chain. - [Pricing and passes](https://x402-avm.github.io/build/pricing.md): Set fixed, per-tool, dynamic and bulk-discount prices on PaymentGate, and sell passes and subscriptions that make calls free for a period. - [Paywall an HTTP API](https://x402-avm.github.io/build/paywall-http-api.md): Charge per request on a FastAPI or Flask route with the official x402 SDK and the Algorand scheme from x402-algorand. - [Pay from Python](https://x402-avm.github.io/build/pay-from-python.md): Call paid MCP tools with paid_mcp_session, and pay x402 HTTP APIs with the official x402 client, within spend limits you set. - [Pay from the browser](https://x402-avm.github.io/build/pay-from-browser.md): Unlock paid content in a web app: the visitor's Algorand wallet signs the payment with x402-avm-js, within spend limits you set. - [Pay from Node.js](https://x402-avm.github.io/build/pay-from-node.md): Pay x402 endpoints from Node.js services, scripts and agents with x402-avm-js and a key from the environment or KMD. - [AI agents](https://x402-avm.github.io/build/ai-agents.md): Give an AI agent a wallet and a budget: it calls paid MCP tools on its own, checks prices, and refuses anything over its limits. - [Identity](https://x402-avm.github.io/build/identity.md): Prove which Algorand address is calling, from Python or any wallet, and verify the proof on your server. - [Run a facilitator](https://x402-avm.github.io/build/facilitator.md): Verify and settle Algorand x402 payments with x402Facilitator, sponsor the network fees, and drive the scheme directly without HTTP. ## Documentation: Go to production - [Networks](https://x402-avm.github.io/production/networks.md): Develop on LocalNet, test on TestNet, run on your own nodes or a private network: CAIP-2 ids, endpoints, funding and network helpers. - [Go to MainNet](https://x402-avm.github.io/production/mainnet.md): A go-live checklist for a paid service on Algorand MainNet: USDC pricing and opt-ins, funding the fee payer, keys, workers, one config for every network, simulation and monitoring. - [Security](https://x402-avm.github.io/production/security.md): The attacks ai-economy-sdk, x402-algorand and x402-avm-js are built to resist, where each protection lives, and how to share the replay store across workers. ## API reference: Overview - [API reference](https://x402-avm.github.io/reference/index.md): Reference for every public object of ai-economy-sdk, x402-algorand and x402-avm-js, generated from the source. - [Packages and versions](https://x402-avm.github.io/reference/packages.md): Install commands, supported runtimes, dependency ranges and upgrade notes for ai-economy-sdk, x402-algorand and x402-avm-js. ## API reference: Protocol - [AVM exact scheme](https://x402-avm.github.io/reference/protocol/avm-exact-scheme.md): Wire format, atomic group layout, verification steps and settlement of the x402 exact scheme on Algorand. - [HTTP 402 response reference](https://x402-avm.github.io/reference/protocol/http-402.md): The PAYMENT-REQUIRED, PAYMENT-SIGNATURE and PAYMENT-RESPONSE headers of a real Algorand x402 payment, decoded field by field. - [Errors and error codes](https://x402-avm.github.io/reference/errors.md): Every verification and settlement failure reason of the Algorand exact scheme, and the exception classes of ai-economy-sdk, x402-algorand and x402-avm-js. ## API reference: ai-economy-sdk - [ai-economy-sdk reference](https://x402-avm.github.io/reference/python/ai-economy-sdk/index.md): Payment-gated MCP servers and paid MCP client sessions on Algorand. ## API reference: ai-economy-sdk / Server - [PaymentGate](https://x402-avm.github.io/reference/python/ai-economy-sdk/payment-gate.md): Payment gate protecting FastMCP server tools with x402 on Algorand. - [AIEconomySDK](https://x402-avm.github.io/reference/python/ai-economy-sdk/ai-economy-sdk.md): Payment-gated MCP server SDK. - [DefaultAvmSigner](https://x402-avm.github.io/reference/python/ai-economy-sdk/default-avm-signer.md): A default implementation of AvmSigner for convenience. - [ChainReader](https://x402-avm.github.io/reference/python/ai-economy-sdk/chain-reader.md): Reader for Algorand blockchain state via an Indexer client. - [SettleOnSuccessMiddleware](https://x402-avm.github.io/reference/python/ai-economy-sdk/settle-on-success-middleware.md): FastMCP middleware that settles payments on chain only upon tool success. ## API reference: ai-economy-sdk / Client - [paid_mcp_session](https://x402-avm.github.io/reference/python/ai-economy-sdk/paid-mcp-session.md): Open an MCP session that pays for tool calls with x402 on Algorand. ## API reference: ai-economy-sdk / Identity - [make_identity_txn](https://x402-avm.github.io/reference/python/ai-economy-sdk/make-identity-txn.md): Create an unsigned identity proof payment transaction. - [sign_identity_txn](https://x402-avm.github.io/reference/python/ai-economy-sdk/sign-identity-txn.md): Create and sign an identity proof transaction, returning the X-Identity-Txn header. - [verify_identity_txn](https://x402-avm.github.io/reference/python/ai-economy-sdk/verify-identity-txn.md): Verify an X-Identity-Txn header value against timestamp skew and Algorand signature. - [sign_identity](https://x402-avm.github.io/reference/python/ai-economy-sdk/sign-identity.md): Generate legacy identity verification headers signed with an Algorand private key. - [verify_identity](https://x402-avm.github.io/reference/python/ai-economy-sdk/verify-identity.md): Verify identity headers against timestamp skew and Algorand signature. ## API reference: ai-economy-sdk / Networks - [resolve_network](https://x402-avm.github.io/reference/python/ai-economy-sdk/resolve-network.md): Return the CAIP-2 id for a network name or id, and register it with x402. - [genesis_hash_for](https://x402-avm.github.io/reference/python/ai-economy-sdk/genesis-hash-for.md): Return the full 44-character base64 genesis hash for a network. - [endpoints_for](https://x402-avm.github.io/reference/python/ai-economy-sdk/endpoints-for.md): Default algod/indexer endpoints: AlgoNode for MainNet/TestNet, LocalNet for anything else. - [usdc_asset_id](https://x402-avm.github.io/reference/python/ai-economy-sdk/usdc-asset-id.md): Circle USDC's asset id on MainNet/TestNet; None elsewhere. - [is_public](https://x402-avm.github.io/reference/python/ai-economy-sdk/is-public.md): Check whether a network identifier represents public MainNet or TestNet. - [register_network](https://x402-avm.github.io/reference/python/ai-economy-sdk/register-network.md): Register an Algorand network in x402's network tables (no-op for MainNet/TestNet, which are built in). - [network_from_algod](https://x402-avm.github.io/reference/python/ai-economy-sdk/network-from-algod.md): Derive the CAIP-2 network id from an algod client and register it. - [Endpoints](https://x402-avm.github.io/reference/python/ai-economy-sdk/endpoints.md): Connection parameters for Algorand node services. ## API reference: ai-economy-sdk / Errors - [AIEconomyError](https://x402-avm.github.io/reference/python/ai-economy-sdk/ai-economy-error.md): Base class for every exception the SDK raises deliberately. - [ConfigurationError](https://x402-avm.github.io/reference/python/ai-economy-sdk/configuration-error.md): Invalid arguments or configuration, detected before any payment is attempted. - [UnknownNetworkError](https://x402-avm.github.io/reference/python/ai-economy-sdk/unknown-network-error.md): A network name or CAIP-2 identifier could not be resolved. - [AlgodClientRequiredError](https://x402-avm.github.io/reference/python/ai-economy-sdk/algod-client-required-error.md): An operation needs an algod connection but the signer was created without one. - [PaymentVerificationError](https://x402-avm.github.io/reference/python/ai-economy-sdk/payment-verification-error.md): A payment transaction group failed verification (for example, algod simulation). - [PaymentRequiredError](https://x402-avm.github.io/reference/python/ai-economy-sdk/payment-required-error.md): A priced tool was invoked without a verified payment. - [SettlementError](https://x402-avm.github.io/reference/python/ai-economy-sdk/settlement-error.md): A verified payment could not be settled on chain after the tool succeeded. - [SpendLimitExceededError](https://x402-avm.github.io/reference/python/ai-economy-sdk/spend-limit-exceeded-error.md): The buyer's own spend controls refused a payment, so nothing was signed or sent. ## API reference: ai-economy-sdk - [Constants](https://x402-avm.github.io/reference/python/ai-economy-sdk/constants.md): Network ids, the pass note prefix and the legacy identity header names exported by ai_economy_sdk. ## API reference: x402-algorand - [x402-algorand reference](https://x402-avm.github.io/reference/python/x402-algorand/index.md): The Algorand (AVM) exact payment scheme as a plugin for the official x402 Python SDK. ## API reference: x402-algorand / Registration - [register_exact_avm_client](https://x402-avm.github.io/reference/python/x402-algorand/register-exact-avm-client.md): Register AVM exact payment schemes to x402Client. - [register_exact_avm_server](https://x402-avm.github.io/reference/python/x402-algorand/register-exact-avm-server.md): Register AVM exact payment schemes to x402ResourceServer. - [register_exact_avm_facilitator](https://x402-avm.github.io/reference/python/x402-algorand/register-exact-avm-facilitator.md): Register AVM exact payment schemes to x402Facilitator. ## API reference: x402-algorand / Schemes - [ExactAvmClientScheme](https://x402-avm.github.io/reference/python/x402-algorand/exact-avm-client-scheme.md): AVM client implementation for the Exact payment scheme (V2). - [ExactAvmServerScheme](https://x402-avm.github.io/reference/python/x402-algorand/exact-avm-server-scheme.md): AVM server implementation for the Exact payment scheme (V2). - [ExactAvmFacilitatorScheme](https://x402-avm.github.io/reference/python/x402-algorand/exact-avm-facilitator-scheme.md): AVM facilitator implementation for the Exact payment scheme (V2). ## API reference: x402-algorand / Signers - [PayerAvmSigner](https://x402-avm.github.io/reference/python/x402-algorand/payer-avm-signer.md): Client-side signer (`ClientAvmSigner`) for a single Algorand account. - [ServerAvmSigner](https://x402-avm.github.io/reference/python/x402-algorand/server-avm-signer.md): Facilitator-side signer (`FacilitatorAvmSigner`) backed by private keys and algod. ## API reference: x402-algorand / Signer protocols - [ClientAvmSigner](https://x402-avm.github.io/reference/python/x402-algorand/client-avm-signer.md): Protocol for AVM client-side signing operations. - [FacilitatorAvmSigner](https://x402-avm.github.io/reference/python/x402-algorand/facilitator-avm-signer.md): Protocol for AVM facilitator-side signing operations. ## API reference: x402-algorand / Types - [ExactAvmPayload](https://x402-avm.github.io/reference/python/x402-algorand/exact-avm-payload.md): Exact payment payload for AVM networks. - [DecodedTransactionInfo](https://x402-avm.github.io/reference/python/x402-algorand/decoded-transaction-info.md): Information extracted from a decoded Algorand transaction. - [TransactionGroupInfo](https://x402-avm.github.io/reference/python/x402-algorand/transaction-group-info.md): Information about a decoded transaction group. ## API reference: x402-algorand / Network utilities - [caip2_from_genesis_hash](https://x402-avm.github.io/reference/python/x402-algorand/caip2-from-genesis-hash.md): Derive CAIP-2 network identifier from an Algorand genesis hash. - [normalize_network](https://x402-avm.github.io/reference/python/x402-algorand/normalize-network.md): Normalize network identifier to CAIP-2 format. - [register_network](https://x402-avm.github.io/reference/python/x402-algorand/register-network.md): Register a custom Algorand network (e.g. - [get_genesis_hash](https://x402-avm.github.io/reference/python/x402-algorand/get-genesis-hash.md): Get the full base64 genesis hash for a network. - [network_from_genesis_hash](https://x402-avm.github.io/reference/python/x402-algorand/network-from-genesis-hash.md): Determine CAIP-2 network from genesis hash. - [is_valid_network](https://x402-avm.github.io/reference/python/x402-algorand/is-valid-network.md): Check if a network identifier is valid. - [get_network_config](https://x402-avm.github.io/reference/python/x402-algorand/get-network-config.md): Get configuration for a network. - [get_usdc_asa_id](https://x402-avm.github.io/reference/python/x402-algorand/get-usdc-asa-id.md): Get the USDC ASA ID for a network. ## API reference: x402-algorand / Transaction utilities - [decode_transaction_bytes](https://x402-avm.github.io/reference/python/x402-algorand/decode-transaction-bytes.md): Decode transaction bytes to DecodedTransactionInfo. - [decode_base64_transaction](https://x402-avm.github.io/reference/python/x402-algorand/decode-base64-transaction.md): Decode a base64-encoded transaction. - [decode_payment_group](https://x402-avm.github.io/reference/python/x402-algorand/decode-payment-group.md): Decode a payment group from base64 strings. - [encode_transaction_group](https://x402-avm.github.io/reference/python/x402-algorand/encode-transaction-group.md): Encode a list of transaction bytes to base64 strings. - [validate_no_security_risks](https://x402-avm.github.io/reference/python/x402-algorand/validate-no-security-risks.md): Validate that a transaction has no security risks (per-transaction checks). - [validate_fee_payer_transaction](https://x402-avm.github.io/reference/python/x402-algorand/validate-fee-payer-transaction.md): Validate a fee payer transaction. - [is_valid_address](https://x402-avm.github.io/reference/python/x402-algorand/is-valid-address.md): Validate an Algorand address format. ## API reference: x402-algorand / Amount utilities - [parse_money_to_decimal](https://x402-avm.github.io/reference/python/x402-algorand/parse-money-to-decimal.md): Parse money value to decimal. - [to_atomic_amount](https://x402-avm.github.io/reference/python/x402-algorand/to-atomic-amount.md): Convert decimal amount to atomic units. - [from_atomic_amount](https://x402-avm.github.io/reference/python/x402-algorand/from-atomic-amount.md): Convert atomic units to decimal amount. ## API reference: x402-algorand / Errors - [X402AlgorandError](https://x402-avm.github.io/reference/python/x402-algorand/x402-algorand-error.md): Base class for all exceptions raised by x402-algorand. - [NetworkError](https://x402-avm.github.io/reference/python/x402-algorand/network-error.md): A network identifier is malformed, unsupported, or not registered. - [NetworkMismatchError](https://x402-avm.github.io/reference/python/x402-algorand/network-mismatch-error.md): An algod node is connected to a different network than the one requested. - [TransactionDecodeError](https://x402-avm.github.io/reference/python/x402-algorand/transaction-decode-error.md): Bytes or base64 text could not be decoded as an Algorand transaction. - [SigningError](https://x402-avm.github.io/reference/python/x402-algorand/signing-error.md): A signer could not sign: bad key material or an address it does not manage. - [SimulationError](https://x402-avm.github.io/reference/python/x402-algorand/simulation-error.md): An algod `simulate` call reported that the transaction group would fail. ## API reference: x402-algorand - [Constants](https://x402-avm.github.io/reference/python/x402-algorand/constants.md): Network ids, genesis hashes, USDC asset ids and protocol limits exported by x402_algorand. ## API reference: x402 core (upstream) - [Core classes](https://x402-avm.github.io/reference/x402/core.md): x402Client, x402ResourceServer and x402Facilitator from the official x402 Python SDK, as used with x402-algorand. - [Schemas](https://x402-avm.github.io/reference/x402/schemas.md): PaymentRequired, PaymentRequirements, PaymentPayload, VerifyResponse and SettleResponse from the official x402 Python SDK. - [HTTP integration](https://x402-avm.github.io/reference/x402/http.md): Header encoding, HTTP clients and server middleware from the official x402 Python SDK. ## API reference: x402-avm-js - [x402-avm-js reference](https://x402-avm.github.io/reference/js/index.md): Every export of x402-avm-js, generated from the TSDoc in src/index.ts and src/errors.ts. ## API reference: x402-avm-js / Payments - [payForRequirement](https://x402-avm.github.io/reference/js/pay-for-requirement.md): Helper to execute full payment flow for an x402 payment challenge. - [decodePaymentRequired](https://x402-avm.github.io/reference/js/decode-payment-required.md): Decode a base64-encoded PAYMENT-REQUIRED header value into a PaymentRequired object. - [parsePaymentRequired](https://x402-avm.github.io/reference/js/parse-payment-required.md): Validate untrusted input (for example a decoded PAYMENT-REQUIRED header) and return it as a {@link PaymentRequired}. - [selectRequirement](https://x402-avm.github.io/reference/js/select-requirement.md): Select the first acceptable payment requirement matching the payer's network. - [buildExactAvmGroup](https://x402-avm.github.io/reference/js/build-exact-avm-group.md): Build atomic transaction group for Exact AVM payment scheme. - [encodePaymentHeader](https://x402-avm.github.io/reference/js/encode-payment-header.md): Encode a payment payload into a base64-encoded PAYMENT-SIGNATURE header. ## API reference: x402-avm-js / Spend controls - [checkSpendControls](https://x402-avm.github.io/reference/js/check-spend-controls.md): Check a requirement against spend controls. - [SpendControls](https://x402-avm.github.io/reference/js/spend-controls.md): Client-side limits checked before anything is signed. - [AmountLimit](https://x402-avm.github.io/reference/js/amount-limit.md): A limit in base units: bigint, a non-negative safe integer, a decimal string, or `Infinity` for no cap. - [DEFAULT_MAX_AMOUNT](https://x402-avm.github.io/reference/js/default-max-amount.md): Default per-payment cap in base units (1 ALGO, or 1 USDC) applied when `maxAmount` is not set. ## API reference: x402-avm-js / Identity - [buildIdentityTxn](https://x402-avm.github.io/reference/js/build-identity-txn.md): Build an identity transaction for wallet ownership proof. - [encodeIdentityHeader](https://x402-avm.github.io/reference/js/encode-identity-header.md): Encode signed identity transaction bytes to base64 string for the X-Identity-Txn header. ## API reference: x402-avm-js / Networks - [resolveNetwork](https://x402-avm.github.io/reference/js/resolve-network.md): Resolve a network name, alias, or legacy ID into a canonical CAIP-2 identifier. - [networkFromGenesisHash](https://x402-avm.github.io/reference/js/network-from-genesis-hash.md): Derive the canonical CAIP-2 identifier from a network's genesis hash per the Algorand profile. - [networkFromAlgod](https://x402-avm.github.io/reference/js/network-from-algod.md): Query an algod client for its current suggested transaction parameters and return its CAIP-2 identifier. - [algodClient](https://x402-avm.github.io/reference/js/algod-client.md): Create an Algodv2 client for a named network or custom endpoint. - [MAINNET](https://x402-avm.github.io/reference/js/mainnet.md): MainNet network constants and public AlgoNode endpoints. - [TESTNET](https://x402-avm.github.io/reference/js/testnet.md): TestNet network constants and public AlgoNode endpoints. - [LOCALNET_ENDPOINTS](https://x402-avm.github.io/reference/js/localnet-endpoints.md): LocalNet endpoints and token. ## API reference: x402-avm-js / Types - [PaymentRequired](https://x402-avm.github.io/reference/js/payment-required.md): Decoded payload of the HTTP 402 PAYMENT-REQUIRED header. - [PaymentRequirements](https://x402-avm.github.io/reference/js/payment-requirements.md): Payment requirements specified by an x402 server. - [ResourceInfo](https://x402-avm.github.io/reference/js/resource-info.md): Metadata about the protected resource in an x402 payment challenge. - [BuildGroupResult](https://x402-avm.github.io/reference/js/build-group-result.md): Result of building an atomic transaction group for the exact AVM payment scheme. - [AlgorandNetwork](https://x402-avm.github.io/reference/js/algorand-network.md): Network configuration and endpoints for an Algorand network. ## API reference: x402-avm-js / Errors - [X402AvmError](https://x402-avm.github.io/reference/js/x402-avm-error.md): Typed errors thrown by x402-avm-js. - [SpendLimitExceededError](https://x402-avm.github.io/reference/js/spend-limit-exceeded-error.md): The requested amount is above the client's spend cap. - [PaymentNotAllowedError](https://x402-avm.github.io/reference/js/payment-not-allowed-error.md): The requirement's asset, network or recipient is not on the caller's allow list. - [InvalidPaymentRequiredError](https://x402-avm.github.io/reference/js/invalid-payment-required-error.md): The PAYMENT-REQUIRED header or object is malformed, or a requirement in it is not a valid exact-AVM offer. - [NoSupportedRequirementError](https://x402-avm.github.io/reference/js/no-supported-requirement-error.md): The challenge offers nothing this client can pay (`accepts` is empty). - [NetworkMismatchError](https://x402-avm.github.io/reference/js/network-mismatch-error.md): None of the offered requirements is for the network the wallet is on, or a requirement's genesis does not match. - [UnknownNetworkError](https://x402-avm.github.io/reference/js/unknown-network-error.md): A network name or CAIP-2 identifier is not recognised, or has no default endpoint. - [InvalidOptionsError](https://x402-avm.github.io/reference/js/invalid-options-error.md): A spend-control option is malformed (for example a negative or non-integer maxAmount). ## Resources - [Troubleshooting](https://x402-avm.github.io/resources/troubleshooting.md): Fixes for common problems with LocalNet, networks, opt-ins, balances, prices and payments. - [FAQ](https://x402-avm.github.io/resources/faq.md): Short answers to common questions about x402 on Algorand and the x402-avm packages, with links to the full explanation. - [Glossary](https://x402-avm.github.io/resources/glossary.md): Terms used across the x402-avm documentation. - [Changelog](https://x402-avm.github.io/resources/changelog.md): Notable changes to ai-economy-sdk, x402-algorand and x402-avm-js, newest first. - [Docs for AI tools](https://x402-avm.github.io/resources/ai-tools.md): llms.txt, llms-full.txt and Markdown versions of every page for coding assistants, and the AGENTS.md file in each x402-avm repository.