Quickstart
This guide will help you choose the right setup for your use case and get started with x402 in minutes.
Choose Your Role
x402 has two sides: servers (merchants who sell access to resources) and clients (buyers who pay for access). You may need one or both depending on your project.
Server Options
If you want to accept x402 payments on your API or service, pick a server framework below.
TypeScript
| Framework | Best For | Guide |
|---|---|---|
| Express | Traditional Node.js APIs, broad ecosystem support | Express Server Guide |
| Hono | Edge-first APIs, lightweight and fast | Hono Server Guide |
Python
| Framework | Best For | Guide |
|---|---|---|
| FastAPI | Modern async APIs, automatic docs, type safety | FastAPI Server Guide |
| Flask | Simple APIs, rapid prototyping | Flask Server Guide |
Client Options
If you want to pay for x402-protected resources, pick a client library below.
TypeScript
| Library | Best For | Guide |
|---|---|---|
| Fetch | Native browser and Node.js, no dependencies | Fetch Client Guide |
| Axios | Feature-rich HTTP client, interceptors | Axios Client Guide |
Python
| Library | Best For | Guide |
|---|---|---|
| httpx | Modern async HTTP, recommended for new projects | httpx Client Guide |
| requests | Widely adopted, synchronous HTTP | requests Client Guide |
Environment Variables
Regardless of which framework you choose, you will need the following environment variables configured in your project.
Required
# The facilitator that verifies and settles payments
FACILITATOR_URL=https://facilitator.svmacc.tech
# Your Solana wallet address (receives payments if you are a server)
ADDRESS=<your-solana-wallet-address>
# The Solana network to use
NETWORK=solana-devnetNetwork Options
| Value | Description |
|---|---|
solana-devnet | Solana devnet. Use this for development and testing. Transactions use devnet USDC and cost nothing. |
solana | Solana mainnet. Use this for production. Transactions use real USDC. |
Tip: Start with
solana-devnetwhile building and testing. Switch tosolanawhen you are ready to go live.
Getting a Wallet Address
You need a Solana wallet address to send or receive payments. If you do not have one:
- Install a Solana wallet such as Phantom or Solflare.
- Create a new wallet and copy your public address.
- For devnet testing, airdrop devnet SOL using the Solana Faucet.
Next Steps
Pick a guide from the tables above and follow the step-by-step instructions:
- Selling access? Start with a server guide.
- Buying access? Start with a client guide.