Quick Start
This guide will help you create your first x402 payment workflow in n8n. We’ll set up a wallet, fund it with test tokens, and make a payment-protected API request.
Step 1: Setup Your Wallet
Section titled “Step 1: Setup Your Wallet”Create Wallet Setup Workflow
Section titled “Create Wallet Setup Workflow”- In n8n, create a new workflow named “x402 Wallet Setup”
- Add a Manual Trigger node
- Add an x402 Wallet Manager node after the trigger
- Connect the nodes
Configure Wallet Manager
Section titled “Configure Wallet Manager”Click on the x402 Wallet Manager node and configure:
- Network:
Devnet(for testing) - Action:
Get Wallet Info
Execute and Get Address
Section titled “Execute and Get Address”- Click “Test Workflow” at the top right
- Check the output panel on the right
- Copy the
walletAddressvalue
Your output will look like:
{ "walletAddress": "9rKnvE7PVbpq4...", "network": "solana-devnet", "balances": { "usdc": 0, "sol": 0 }, "status": "needs_funding", "fundingInstructions": { "steps": [ "Get devnet USDC from: https://spl-token-faucet.com/?token-name=USDC-Dev", "Get devnet SOL: https://faucet.solana.com/", "Wait for confirmation (~30 seconds)", "Re-run this node to verify balance" ] }}Step 2: Fund Your Wallet
Section titled “Step 2: Fund Your Wallet”Get Test USDC
Section titled “Get Test USDC”- Visit: https://spl-token-faucet.com/?token-name=USDC-Dev
- Paste your wallet address
- Click “Confirm Airdrop”
- Wait ~30 seconds
Get Test SOL (for transaction fees)
Section titled “Get Test SOL (for transaction fees)”- Visit: https://faucet.solana.com/
- Paste your wallet address
- Click “Airdrop”
- Wait ~30 seconds
Verify Funding
Section titled “Verify Funding”- Go back to your n8n workflow
- Click “Test Workflow” again
- Check the output - you should now see:
{ "walletAddress": "9rKnvE7PVbpq4...", "network": "solana-devnet", "balances": { "usdc": 10, "sol": 1.5 }, "status": "ready", "message": "Wallet is funded and ready to use!"}Step 3: Test with Mock Server
Section titled “Step 3: Test with Mock Server”Now let’s test making a payment using the built-in mock server.
Create Test Workflow
Section titled “Create Test Workflow”- Create a new workflow named “x402 Payment Test”
- Add these nodes in order:
- Manual Trigger
- x402 Wallet Manager
- x402 Client
Configure Wallet Manager
Section titled “Configure Wallet Manager”In the x402 Wallet Manager node:
- Network:
Devnet - Action:
Get Wallet Info
Set Up Mock Server
Section titled “Set Up Mock Server”-
Create another workflow named “x402 Mock API Server”
-
Add x402 Mock Server node
-
Configure it:
- HTTP Method:
POST - Path:
test-api - Network:
Devnet - Payment Amount:
10000(0.01 USDC) - Description:
Test API access - Mock Response:
{"status": "success", "data": "Test payment worked!"} - Verify On-Chain:
false(off for testing)
- HTTP Method:
-
Activate the workflow (toggle at top right)
-
Copy the webhook URL from the node
Configure Client Node
Section titled “Configure Client Node”In your “x402 Payment Test” workflow, click the x402 Client node:
- Wallet Source:
From Wallet Manager Node - Resource URL: [Paste your webhook URL from mock server]
- HTTP Method:
POST - Request Body:
{} - Auto-Pay:
true - Max Payment Amount:
1(USDC)
Run Your First Payment!
Section titled “Run Your First Payment!”- Ensure the Mock Server workflow is Active
- Go to your Test workflow
- Click “Test Workflow”
- Watch the execution!
You should see:
{ "status": "success", "data": "Test payment worked!", "_x402Payment": { "amount": "0.01", "currency": "USDC", "recipient": "ABC123...", "sender": "9rKnvE7PVbpq4...", "network": "solana-devnet", "timestamp": "2024-01-15T10:30:00.000Z" }}Congratulations! You just made your first x402 payment! 🎉
Step 4: Understanding What Happened
Section titled “Step 4: Understanding What Happened”The x402 Client node automatically:
- Sent first request to your mock server (no payment)
- Received 402 response with payment requirements
- Created payment using your wallet
- Signed transaction on Solana blockchain
- Retried request with payment proof in
X-Paymentheader - Got the data from the protected endpoint
All of this happened automatically in the background!
Optional: Try Different Wallet Sources
Section titled “Optional: Try Different Wallet Sources”The x402 Client supports multiple wallet sources:
Option 1: Saved Wallet (Persistent)
Section titled “Option 1: Saved Wallet (Persistent)”After connecting Wallet Manager once, the wallet is saved:
- Connect Wallet Manager → Run workflow once
- Disconnect Wallet Manager (delete the connection)
- Change Wallet Source to “Saved Wallet (Recommended)”
- Run again - it uses the saved wallet!
This is perfect for scheduled workflows.
Option 2: Private Key (Reusable)
Section titled “Option 2: Private Key (Reusable)”Enter your private key directly (from Wallet Manager output):
- Set Wallet Source to “Private Key (Reusable)”
- Paste your Private Key from Wallet Manager output
- Select Network (Devnet)
- No connection to Wallet Manager needed!
Great for workflows with triggers (schedule, webhook, etc.)
What’s Next?
Section titled “What’s Next?”Now that you’ve made your first payment:
Learn More
Section titled “Learn More”- Wallet Setup Guide - Detailed wallet management
- Payment Flow - How x402 protocol works
- Mock Server - More about testing
Try Examples
Section titled “Try Examples”- Basic Payment - Simple payment workflow
- Scheduled Payments - Automated payments
- Multiple Endpoints - Call multiple APIs
Go to Production
Section titled “Go to Production”- Using Mainnet - Deploy with real USDC
- Payment Limits - Safety configuration
- Error Handling - Handle failures gracefully
Troubleshooting
Section titled “Troubleshooting””Insufficient balance” error
Section titled “”Insufficient balance” error”- Check your wallet balances in Wallet Manager
- Fund with more USDC/SOL from the faucets
- Wait 30 seconds after funding
”No wallet data found” error
Section titled “”No wallet data found” error”- Ensure Wallet Manager is connected to Client
- Check that wallets are on the same network (both Devnet)
- Try re-running Wallet Manager node
”Transaction not found” error
Section titled “”Transaction not found” error”- This is rare - retry the workflow
- RPC nodes can be slow on devnet
- Wait a few seconds and retry
Mock Server not responding
Section titled “Mock Server not responding”- Ensure Mock Server workflow is Active
- Check the webhook URL is correct
- Try regenerating the webhook URL (deactivate → activate)