Welcome to the x402 AI Starter Kit (Solana Edition) documentation. This document provides a detailed, end-to-end guide to the starter kit: architecture, installation, configuration, developer workflows, payment flows using x402 on Solana, API references, examples, troubleshooting, and deployment instructions.
Search for a command to run...
Introduction to x402 AI Starter Kit (Solana Edition)
System architecture and component overview
Required tools and dependencies
Setup and deployment guide
Environment configuration guide
Solana blockchain integration
Understanding the x402 payment protocol
MCP server setup and agent integration
Complete API documentation
Step-by-step examples and tutorials
Testing and debugging guide
Security best practices
Deployment instructions
The x402 AI Starter Kit (Solana Edition) is a reference application demonstrating how AI agents (built with an Agent Development Kit) can request and process payments using the x402 protocol and the Solana blockchain. The starter kit includes:
This kit is ideal for developers building pay-to-use AI services, agent-to-agent commerce, or experimenting with decentralized payment coordination using x402 + Solana.
Before you begin, install the following on your machine:
git clone <REPO_URL> cd x402-ai-starter-kit
# in the root directory (Next.js frontend) npm install # if MCP server has a separate package cd mcp-server && npm install
See the Configuration section below for full details on the env variables. Configure your environment variables in your hosting platform or deployment environment.
Deploy the application to your hosting platform:
Set up your ADK agents with production credentials and configuration. Agents will register in the ADK environment and can be invoked from the UI.
NEXT_PUBLIC_API_BASE_URL=https://api.yourdomain.com # MCP server address NEXT_PUBLIC_ADK_ENDPOINT=https://adk.yourdomain.com # ADK or agent endpoint NEXT_PUBLIC_SOLANA_NETWORK=mainnet-beta NEXT_PUBLIC_DEFAULT_TOKEN_USDC=USDC_MAINNET_MINT_ADDRESS
PORT=4000 SOLANA_CLUSTER=mainnet-beta SOLANA_RPC=https://api.mainnet-beta.solana.com USDC_MINT_ADDRESS=<USDC_MAINNET_MINT>
Keep secrets (private keys, service tokens) out of git and use environment variables or secret managers.
The SDK supports 6 major Solana wallets with priority ranking:
The wallet integration uses a WalletSigner interface abstraction that decouples SDK logic from UI wallet adapter implementation. This ensures:
x402 is a lightweight extension of HTTP payment semantics for agent-to-agent commerce. The important concepts in starter kit context:
{
"amount": "5000",
"currency": "USDC",
"token_mint": "<USDC_MINT_ADDRESS>",
"recipient": "<merchant_sol_address>",
"memo": "x402-payment-for:banana-order-123",
"expires_at": "2025-01-01T00:00:00Z",
"prepared_tx": "<optional_base64_serialized_tx>"
}Prepared transaction mode: the merchant may provide a prepared transaction (unsigned or partially signed) for the payer to sign and submit.
Security note: Never rely solely on off-chain signals for payment completion; always validate on-chain confirmations and expected token amounts.
The MCP server exposes endpoints that agents and the frontend use for payment orchestration. Core endpoints include:
Returns service health and Solana cluster connectivity.
Create a prepared transaction for token transfer
Request:
{
"from": "payerPubkey",
"to": "merchantPubkey",
"amount": "5",
"mint": "USDC_MINT"
}Response:
{ "preparedTxBase64": "...", "recentBlockhash": "..." }Validate a tx signature and token transfer
Request:
{ "signature": "...", "expectedAmount": 5, "mint": "USDC_MINT" }Response:
{ "status": "confirmed", "confirmedSlot": 12345 }This is a compact reference — adapt to your actual code routes.
For monitoring and debugging, use the following approaches:
For deployment to Vercel or other platforms:
Contributions are welcome! Please follow the project's contribution guidelines and submit pull requests for any improvements.
Please refer to the project's LICENSE file for license information.