@blockchainhq-xyz/n8n-nodes-pocket-client
v1.0.2
Published
n8n node for making USDC payments via x402 protocol
Maintainers
Readme
@blockchainhq-xyz/n8n-nodes-pocket-client
n8n community node for making USDC payments in response to HTTP 402 errors. Client-side implementation of x402 protocol.
What It Does
- Parse 402 payment requirements
- Make USDC payments automatically
- Return transaction signatures
- Integrate with any 402-enabled API
Installation
In n8n (Recommended)
- Go to Settings > Community Nodes
- Click Install
- Enter:
@blockchainhq-xyz/n8n-nodes-pocket-client - Click Install
Manual Installation (For Development)
Note: This installs from source code, not npm.
# 1. Clone the server node repository
git clone https://github.com/blockchain-hq/x402-pocket-node-client.git
cd x402-pocket-node-client
# 2. Install dependencies
npm install
# 3. Link the server SDK
npm link x402-client-sdk
# If SDK not published yet, link local SDK first:
# cd /path/to/x402-server-sdk && npm link
# cd /path/to/n8n-nodes-solana-x402 && npm link x402-server-sdk
# 4. Build the node
npm run build
# 5. Set custom extensions path
# If running both server and client nodes, set path to parent folder:
export N8N_CUSTOM_EXTENSIONS="$HOME/x402-n8n-nodes"
# Make it permanent:
echo 'export N8N_CUSTOM_EXTENSIONS="$HOME/x402-n8n-nodes"' >> ~/.zshrc
# Note: Your folder structure should be:
# ~/x402-n8n-nodes/
# ├── n8n-nodes-solana-x402/ (this server node)
# └── n8n-nodes-pocket-client/ (client node, if needed)
# 6. Start n8n
n8n start
# 7. In n8n, search for: "Pocket node client"Operations
1. Parse 402 Response
Extracts payment details from 402 response.
Input: 402 response body Output: Payment details (amount, recipient)
2. Make Payment
Sends USDC to specified address.
Input:
- Recipient address
- Amount (USDC)
- Payment ID (optional)
Output: Transaction signature
3. Parse and Pay
Parse and pay in one step (recommended!)
Input: 402 response body Output: Transaction signature
Credentials
Pocket node client API:
- Network: Devnet or Mainnet
- Wallet Private Key: Base58 encoded
- RPC URL: (optional)
Get Private Key:
solana address -k ~/wallet.json
cat ~/wallet.jsonExample Workflow
Works with Mock Server node for testing:
Solana x402 (Mock Server) → Returns 402
↓
Pocket node client → Parse and Pay
↓
Solana x402 (Mock Server) → Verify Payment
↓
Get ContentOr with real API:
HTTP Request → Get 402 from real API
↓
Pocket node client → Parse and Pay (sends USDC)
↓
HTTP Request → Retry with X-Payment signature
↓
Get ContentUse Cases
| Use Case | Description | |----------|-------------| | Testing with Mock | Use with Solana x402 Mock Server node | | Auto-pay APIs | Automatic payment on 402 | | Content Access | Pay for premium content | | Subscription | Automated renewal | | Pay-per-use | Pay as you go |
Perfect combo: Use with the Solana x402 Mock Server node to test complete payment flows in n8n without building APIs!
Wallet Setup
Devnet (Testing):
# Generate wallet
solana-keygen new -o ~/devnet-wallet.json
# Get SOL (for transaction fees)
solana airdrop 2 YOUR_ADDRESS --url devnet
# Get private key
cat ~/devnet-wallet.jsonMainnet (Production):
- Use existing wallet
- Ensure sufficient USDC balance (and SOL for transaction fees)
- Keep private key secure
Full Payment Flow
1. Request API
2. Get 402 response
3. Use "Parse and Pay"
4. Get signature
5. Retry request with X-Payment header
6. Access grantedSecurity
Best Practices:
- Never commit private keys
- Use environment variables
- Start with small amounts on devnet
- Test thoroughly before mainnet
Troubleshooting
| Issue | Fix | |-------|-----| | Node not visible | Restart n8n, clear cache | | Invalid private key | Use base58 format | | Insufficient balance | Get more USDC (and SOL for fees) | | Transaction failed | Check network and balance |
Networks
Devnet:
- Free testing
- Get SOL via airdrop (for transaction fees)
- Get USDC from faucets or swaps
- Same as mainnet
Mainnet:
- Real USDC
- Purchase from exchange
- Production ready
Resources
Requirements
- n8n: v0.220.0+
- Node.js: v18+
- USDC balance for payments (and SOL for transaction fees)
License
MIT
Contributing
Issues and PRs welcome!
Support
Star if useful!
