Package Information
Documentation
x402 Pocket Nodes for n8n
Seamlessly integrate x402 payment protocol with your n8n workflows. Make HTTP requests to x402-enabled APIs with automatic Solana/USDC payment handling.
šÆ What is x402?
x402 is an HTTP payment protocol that allows APIs to request micropayments for access. Think "HTTP 402 Payment Required" - but actually implemented with Solana blockchain payments.
š¦ Installation
Option 1: n8n Community Nodes (Recommended)
- Open n8n
- Go to Settings ā Community Nodes
- Click Install a community node
- Enter:
@blockchain-hq/n8n-nodes-x402-pocket - Click Install
Option 2: Manual Installation
cd ~/.n8n/nodes
npm install @blockchain-hq/n8n-nodes-x402-pocket
Then restart n8n.
š Quick Start
1. Setup Your Wallet (One-Time)
[Manual Trigger] ā [x402 Wallet Manager]
- Add x402 Wallet Manager node
- Select Devnet (for testing)
- Run the workflow
- Copy the wallet address from output
- Fund it at https://spl-token-faucet.com/
- Re-run to verify funding
2. Make x402 Requests
[Trigger] ā [x402 Wallet Manager] ā [x402 Client] ā [Process Data]
- Add x402 Wallet Manager and x402 Client nodes
- Connect them with a line
- Configure the Client with your API endpoint
- Run! Payments happen automatically
š Full Setup Guide
š§© Included Nodes
x402 Wallet Manager
Generate and manage a persistent Solana wallet for x402 payments.
Features:
- ā Generate wallet once, use everywhere
- ā Check balances (USDC & SOL)
- ā Get funding instructions
- ā Reset wallet if needed
Use Cases:
- Initial wallet setup
- Balance monitoring
- Wallet management
x402 Client
Make HTTP requests to x402-enabled APIs with automatic payment.
Features:
- ā Automatic x402 payment handling
- ā Support for GET, POST, PUT, DELETE
- ā Custom headers and request bodies
- ā Configurable payment limits
- ā Transaction details in output
- ā Works with Wallet Manager or auto-generate mode
Use Cases:
- Access paid AI APIs
- Fetch paid data feeds
- Call micropayment APIs
- Monetize your own services
x402 Mock Server
Test x402 integration without real blockchain transactions.
Features:
- ā Simulates x402 payment flow
- ā No real money needed
- ā Perfect for development
š Examples
Simple Data Fetch
[Schedule: Every hour]
ā
[x402 Wallet Manager]
ā
[x402 Client]
URL: https://api.weather-x402.com/forecast
Method: POST
Body: {"city": "San Francisco"}
ā
[Save to Database]
AI Text Generation
[Webhook Trigger]
ā
[x402 Wallet Manager]
ā
[x402 Client]
URL: https://ai-api.example.com/generate
Method: POST
Body: {"prompt": "{{$json.query}}"}
ā
[Send Response]
Conditional Payments
[Manual Trigger]
ā
[x402 Wallet Manager]
ā
[IF: Balance > 5 USDC?]
ā true
[x402 Client]
URL: https://premium-api.com/data
ā
[Process Results]
š§ Configuration
Wallet Manager Settings
| Setting | Description | Values |
|---|---|---|
| Network | Blockchain network | Devnet, Mainnet |
| Action | What to do | Get Info, Check Balance, Reset Wallet |
Client Settings
| Setting | Description | Default |
|---|---|---|
| Wallet Source | Where to get wallet | Wallet Manager (recommended) |
| Resource URL | x402 API endpoint | - |
| HTTP Method | Request method | POST |
| Request Body | JSON payload | {} |
| Auto-Pay | Automatically pay if required | true |
| Max Payment | Safety limit (USDC) | 1 |
| Headers | Custom HTTP headers | - |
š Security
- š Wallets are stored in n8n's encrypted database
- š Private keys never leave your n8n instance
- š Use Devnet for testing (no real money)
- š Set payment limits to avoid overspending
- š Monitor balances regularly
š Networks
Devnet (Testing)
- Free test tokens
- No real value
- USDC Faucet: https://spl-token-faucet.com/
- SOL Faucet: https://faucet.solana.com/
Mainnet (Production)
- Real money
- Buy USDC on exchanges
- Need SOL for transaction fees
š ļø Development
Build from Source
# Clone the repo
git clone https://github.com/blockchain-hq/x402-pocket-nodes
cd x402-pocket-nodes
# Install dependencies
pnpm install
# Build
pnpm run build
# Link to n8n (for development)
npm link
cd ~/.n8n/nodes
npm link @blockchain-hq/n8n-nodes-x402-pocket
Project Structure
src/
āāā nodes/
ā āāā X402Client/ # Client node
ā āāā X402MockServer/ # Mock server node
ā āāā X402WalletManager/ # Wallet manager node
āāā utils/
ā āāā solana.utils.ts # Solana helpers
ā āāā x402.client.ts # x402 client logic
ā āāā x402.server.ts # x402 server logic
ā āāā x402.types.ts # Type definitions
āāā index.ts # Entry point
š TODO / Roadmap
- Add support for more payment schemes (hashlock, invoice)
- Support for other tokens (SOL, custom SPL tokens)
- Wallet credential type for better security
- Multi-wallet support
- Payment history tracking
- Balance alerts/notifications
- Support for other blockchains (Ethereum, etc.)
š¤ Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Write tests if applicable
- Submit a pull request
š License
MIT License - see LICENSE file
š Links
š¬ Support
- š Check WALLET_SETUP.md for detailed setup guide
- š Report bugs via GitHub Issues
- š” Feature requests welcome!
š Credits
Built with ā¤ļø for the n8n and Solana communities.
Made with n8n š Powered by Solana ā” Following x402 Protocol š³