x402 Integration
Set up pay-per-use payments for smart contract operations on Avalanche networks using Thirdweb.
Thirdweb Required
x402 payment endpoints require Thirdweb as a third-party service provider. You must set up a Thirdweb account and configure your client ID to use x402 payments.
Overview
x402 payments enable pay-per-use smart contract operations on Avalanche networks. Hyperagent integrates with Thirdweb to handle payment processing, wallet connections, and USDC transfers.
Thirdweb Setup
Before configuring x402 payments, you need to set up a Thirdweb account:
- Create an account at thirdweb.com
- Create a new project or use an existing one
- Navigate to your project settings and copy your Client ID
- Ensure your project is configured for Avalanche networks
Configuration
Add your Thirdweb Client ID to your environment variables:
Terminal
# .env file
THIRDWEB_CLIENT_ID=your_client_id_here
# For Docker setup
THIRDWEB_CLIENT_ID=your_client_id_hereAfter setting the environment variable, restart your Hyperagent server. The x402 endpoints will automatically use Thirdweb for payment processing.
Testing
To test x402 payments:
- Ensure your Thirdweb Client ID is configured
- Connect a wallet with USDC on Avalanche testnet
- Make a request to any x402 endpoint (workflows, contracts, deployments)
- Complete the payment flow through Thirdweb
- Verify the operation completes successfully
Testnet First
Always test x402 payments on Avalanche testnet before using mainnet. Ensure you have testnet USDC in your wallet.