12 min
Multi-Network Clients (EVM + Solana)
Learning Objectives
- Register both EVM and Solana payment schemes
- Understand wildcard network registration
- Learn how network selection works
- Handle multi-network signers
Why Multi-Network?
x402 services can accept payments on different blockchains. A server might accept USDC on:
•Base (EVM chain ID 8453)
•Solana Mainnet
•Ethereum Mainnet
Your client needs to support whichever networks the server offers.
The x402 client automatically picks which network to use based on what you've registered and what the server accepts. You don't need to manually choose!
Registering Multiple Schemes
Use registerExactEvmScheme for all EVM chains and registerExactSvmScheme for Solana:
typescript
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { registerExactSvmScheme } from "@x402/svm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
import { createKeyPairSignerFromBytes } from "@solana/kit";
import { base58 } from "@scure/base";
// Create EVM signer (works for Base, Ethereum, Polygon, etc.)
const evmSigner = privateKeyToAccount(
process.env.EVM_PRIVATE_KEY as `0x${string}`
);
// Create Solana signer
const svmSigner = await createKeyPairSignerFromBytes(
base58.decode(process.env.SOLANA_PRIVATE_KEY!)
);
// Register both schemes
const client = new x402Client();
registerExactEvmScheme(client, { signer: evmSigner });
registerExactSvmScheme(client, { signer: svmSigner });
const fetchWithPayment = wrapFetchWithPayment(fetch, client);
// Now handles both EVM and Solana automatically!
const response = await fetchWithPayment('https://api.example.com/data');How Network Selection Works
When a server responds with 402, it includes multiple payment options:
json
{
"x402": 2,
"accepts": [
{
"scheme": "exact",
"network": "eip155:8453", // Base
"amount": "1000"
},
{
"scheme": "exact",
"network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", // Solana Mainnet
"amount": "1000"
}
]
}The client picks the first option that matches a registered scheme. In this case, since you registered EVM first, it would use Base.
Registration order matters! The client tries schemes in the order you registered them.
Interactive Playground
typescript
Output
Click "Run Code" to see the output