Add Algorand AVM Support
Add Algorand (AVM) Support to x402 Protocol (Spec & TS)
Description
This PR adds comprehensive support for the Algorand Virtual Machine (AVM) to the x402 protocol, enabling payment verification and settlement on Algorand networks (both mainnet and testnet). The implementation follows the exact scheme pattern established for EVM and SVM networks, providing a consistent developer experience across all supported blockchains.
Check it live, set to receive 0.01 USDC with paid fees on Algorand TESTNET, here: X402-Algorand
Key additions and modifications include:
- AVM Client Implementation: Added client-side functionality for creating and signing Algorand transactions, including support for both native ALGO and ASA (Algorand Standard Asset) payments.
- AVM Facilitator: Implemented verification and settlement logic for Algorand transactions, with support for fee delegation
-
Wallet Integration: Added
use-walletfor universal Algorand wallets support. - Middleware Support: Extended the x402-next middleware to handle Algorand payment requirements
- Paywall UI: Enhanced the PaywallApp component to support Algorand payments and asset transfers
- Site: Added Algorand networks support to site.
- Type Definitions: Added comprehensive type definitions for Algorand-specific components
- Documentation: Added JSDoc comments to all new functions and updated existing documentation
This implementation enables developers to easily integrate Algorand payments into their applications using the same familiar x402 API patterns used for other blockchains.
Features
- Delivers both payment with Algo or Assets
- Uses Lease field for PaymentRequirement attestation.
- Delivers configurable fee delegation (by feePayer config).
- Handles settlement and succeeds on Transaction finality thanks to Algorand's under 3 seconds transaction finality.
Tests
All tests have passed
All lints are checked and passed:
Checklist
- [x] I have formatted and linted my code
- [x] All new and existing tests pass
- [x] My commits are signed by @emg110
Author
Contributed by @emg110 from @GoPlausible
Future roadmap
- Comprehensive contributions to x402 MCP
- Comprehensive contributions to x402 A2A
- Comprehensive contributions to x402 AP2
The env format
NEXT_PUBLIC_FACILITATOR_URL=http://localhost:3000/facilitator
RESOURCE_WALLET_ADDRESS=MPY54CLPH2OKEGC6S5N2LDAFDNO5BVNV532NBZ5VD6GOND3STPNXZYXOFE
NETWORK=algorand-testnet
PRIVATE_KEY= ALGORAND MNEMONIC
ASSET=10458941
PRICE=0.01
ALGOD_SERVER=https://testnet-api.algonode.cloud
ALGOD_TOKEN=
ALGOD_PORT=
ALGORAND_FEE_PAYER=MPY54CLPH2OKEGC6S5N2LDAFDNO5BVNV532NBZ5VD6GOND3STPNXZYXOFE
@emg110 is attempting to deploy a commit to the Coinbase Team on Vercel.
A member of the Team first needs to authorize it.
🟡 Heimdall Review Status
| Requirement | Status | More Info | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Reviews |
🟡
0/1
|
Denominator calculation
|
Appreciations in advance for your time to review this PR. I also have a question: Where is best to add the comprehensive documentation for Algorand developers and end users and also supported ENV variables for AVM developers in README files in the project structure or perhaps in root README in a section. Thanks for your help.
Hello Coinbase team,
It has been a while and I have many new contributions on A2A and AP2 integrations for x402 that are waiting on this one to be merged.
The temporary (before merge of this) avm supporting NPM packages x402-avm, x402-avm-fetch,... are published to NPM and are in work in some implementations. Many examples on each x402 MCP, A2A and AP2 integrations with ref implementations are ready to go as a PR. These are the first of their kinds so timing would be of vital importance in Agentic era.
One of the exciting new things coming up is dynamic x402 payments implementation and examples, usable for shopping flow scenarios where the resources are dynamic and based on Shopper intents and cart. This is available in MCP and A2A implementations.
On top of that with x402-AP2 integration all that will be identifiable, verifiable and with provenance.
Let's Go and make that being 10x better happen together
Coinbase Team,
Can this be reviewed and merged? Our project is currently on hold because of this. Thanks!
This PR gets closed by Author in favor and support of Algorand Foundation proposal . AF and GoPlausible have joined efforts and collaborations on X402 development. The reference implementation and examples codes will be adopted and added to that PR as well. This closed PR will still be preserved as a backup, just in case of alternative approach requirement.