x402-algorand is derived from GoPlausible’s x402-avm 2.0.2 and plugs into the official x402 Python SDK (x402>=2.28,<3) maintained by the x402 Foundation.
Install
ai-economy-sdkalso installsx402-algorand, the officialx402package, FastMCP, the MCP SDK,py-algorand-sdk, httpx, Starlette, FastAPI and uvicorn.- The official SDK’s framework integrations need their extras, for example
pip install "x402[flask]"for the Flask middleware. x402-avm-jsis an ES module with one runtime dependency,algosdk(v3); install it alongside to create clients and sign. It uses only standard web APIs (Uint8Array,TextEncoder,TextDecoder) and no Node built-ins such asBuffer, so it runs in browsers, Node.js, workers and edge runtimes without polyfills.
x402 version is the one pip resolved, 2.28 or later. The Node.js check prints algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k.
Compatibility
From each package’spyproject.toml / package.json and CI matrix:
fastmcp 4.x and mcp 2.x are excluded on purpose: the 0.4.1 release notes record upstream httpx changes in those majors that affect x402 compatibility. These docs were checked on Python 3.14 with x402 2.28.0, fastmcp 3.4.11 and mcp 1.30.0, and on Node.js 24 with algosdk 3.9.0.
Previous releases: ai-economy-sdk 0.4.1 and x402-algorand 0.2.1 declared Python 3.10 to 3.13 (>=3.10) and the same x402, fastmcp and mcp ranges; ai-economy-sdk 0.4.1 required x402-algorand>=0.2.0. x402-avm-js 0.3.1 declared Node.js >=18.
Every release: Changelog.
Upgrade notes
ai-economy-sdk 0.5
0.5.0 is a security release: in 0.4.x the gate did not cover the Streamable HTTP transport or SSE apps mounted under a path prefix, so priced tools could be called without paying there (details). After upgrading:- Pass
transport=towrap()explicitly."streamable-http"is recommended; withouttransport=,wrap()still serves SSE and emits aFutureWarning. - Point clients at the transport you serve:
paid_mcp_sessionuses Streamable HTTP for URLs whose path ends in/mcp, and SSE for other URLs (or passtransport=). - Errors have their own classes (Errors). Each still subclasses the type raised in 0.4.x, so
except ValueError/except RuntimeError/except ToolErrorhandlers keep working. - A pricing function that accepts neither
(args, sender)nor(args)raisesConfigurationErrorwhen the tool is registered withAIEconomySDK.add_tool(), instead of failing per request. ChainReaderandPaymentGatestill treat failed indexer and algod lookups as “no usage, subscription or pass”, but other exceptions now propagate.DefaultAvmSigner.private_keyis read-only and deprecated; keep your own reference to the key.sign_identity()is deprecated in favour ofsign_identity_txn().- 0.5.1: a payment refused by the buyer’s spend controls raises
SpendLimitExceededErrorinstead of anExceptionGroup.
ai-economy-sdk from 0.3
- Network ids are CAIP-2 short ids (
algorand:plus 32 characters), for examplealgorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k. Legacy 44-character ids are still accepted everywhere and converted. x402-algorandis a plugin for the officialx402package (2.28 or later) instead of a fork of it.
x402-algorand 0.3
0.3.0 is backward compatible with code written for 0.2.x. Changes you may notice:- Hand-written signers can be replaced by
PayerAvmSignerandServerAvmSigner. - Unsupported networks, wrong-network algod nodes and undecodable transactions raise
NetworkError,NetworkMismatchErrorandTransactionDecodeError(all stillValueErrors). settle()returns the ID of the buyer’s payment transaction (paymentGroup[paymentIndex]), as the specification requires. With a fee payer, 0.2.x returned the fee payer transaction’s ID.- Payments authorized by a k-of-n multisig, a logic signature, or the auth address of a rekeyed account are accepted. A rekey pair is only accepted when the second rekey returns authority to the sender.
- The V1 facilitator and client wrappers accept the official SDK’s
PaymentPayloadV1/PaymentRequirementsV1models, so V1 payments routed throughx402Facilitator/x402Clientwork. x402_algorand.__version__and apy.typedmarker; Python 3.14 is supported.
x402-algorand from 0.1.x
0.2.0 had two breaking changes:-
A plugin, not a fork. 0.1.x installed its own copy of the top-level
x402package. 0.2.0 ships onlyx402_algorandand depends on the officialx402package. -
Short CAIP-2 ids. The official SDK validates network ids with
^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}$, so ids use 32 characters of the URL-safe base64 genesis hash. Legacy 44-character ids are still accepted bynormalize_network()and converted.
x402-avm-js 0.4
- Default spend cap. Payments above 1,000,000 base units are refused. To pay more, pass
{ maxAmount: ... }as the last argument ofpayForRequirementorbuildExactAvmGroup. - Node.js 20 or later. Node.js 18 is no longer supported.
- Validation.
decodePaymentRequiredvalidates the decoded shape and throwsInvalidPaymentRequiredError(0.3 returned whatever JSON it found).selectRequirement,encodePaymentHeaderandpayForRequirementtakePaymentRequiredinstead ofPaymentRequired | any;extraandextensionsvalues areunknowninstead ofany. - Typed errors. Catch
X402AvmErrorsubclasses or checkerror.codeinstead of matching messages. - 0.4.1:
algodClient('localnet')connects to port 4001; earlier versions connected to port 80.
x402-avm-js from 0.2
0.3 uses the Algorand CAIP-2 profile for network ids:algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k for MainNet and algorand:SGO1GKSzyE7IEPItTxCByw9x8FmnrCDe for TestNet. Legacy 44-character ids are still accepted by resolveNetwork and selectRequirement, so existing servers keep working.