npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@blockchainhq-xyz/n8n-nodes-pocket-mock

v1.0.3

Published

n8n node for Solana x402 payment protocol - Return HTTP 402 Payment Required

Readme

Pocket node Mock

Mock server node for testing x402 payment flows in n8n. Test payment logic without creating actual APIs!

npm version License: MIT

What It Does

This is a mock server node that simulates a payment-required API server directly in n8n:

  • Return HTTP 402 Payment Required (without building an API)
  • Verify SOL payments on-chain
  • Test payment flows in n8n
  • No separate API server needed
  • Perfect for development and prototyping

Why Mock? Test your payment logic end-to-end in n8n without deploying actual APIs. Great for learning, testing, and prototyping!

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-mock.git
cd x402-pocket-node-mock

# 2. Install dependencies
npm install

# 3. Link the server SDK
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/
#   ├── x402-pocket-node-mock/         (this server node)
#   └── n8n-nodes-solana-x402-client/  (client node, if needed)

# 6. Start n8n
n8n start

# 7. In n8n, search for: "Pocket node Mock"

Operations

1. Return 402 Payment Required

Returns 402 response requiring SOL payment.

Input:

  • Amount (SOL): e.g., 0.01
  • Resource ID: optional

Output:

{
  "statusCode": 402,
  "body": {
    "paymentOptions": [{
      "amount": "0.01",
      "recipient": "YOUR_WALLET",
      "token": "USDC"
    }]
  }
}

2. Verify Payment

Verifies SOL payment on-chain.

Input:

  • Transaction Signature
  • Expected Amount (SOL)
  • Max Age (seconds)

Output:

{
  "valid": true,
  "signature": "5VERv8...",
  "amount": 0.01,
  "from": "PAYER_ADDRESS",
  "to": "YOUR_WALLET"
}

Credentials

Pocket Mock API:

  • Network: Devnet or Mainnet
  • Recipient Address: Your wallet
  • RPC URL: (optional)

Mock Server Workflow

Test payment flows without building an API:

Manual Trigger → Pocket node Mock (Mock Server)
                  Return 402 with requirements
    ↓
Solana x402 Client → Parse and Pay
                      (makes real payment on devnet)
    ↓
Pocket node Mock (Mock Server) → Verify Payment
                             (checks real transaction)
    ↓
IF Valid → Return Mock Content
    ↓
IF Invalid → Return 403 Error

This simulates: Client requesting paid content → Server requiring payment → Client paying → Server verifying → Access granted

No real API needed! Perfect for testing, learning, and prototyping.

Use Cases

| Use Case | Description | |----------|-------------| | Learning x402 | Understand payment protocol without APIs | | Testing Payment Flows | Validate payment logic in n8n | | Prototyping | Quick proof-of-concept for paid features | | Development | Test before building real API | | Demo | Show payment flows to stakeholders |

Real-world deployment: Use the x402 Server SDK in your actual Node.js/Express API. This mock node is for testing!

Security

Always:

  • Set Max Age (recommended: 300s)
  • Store used signatures in database
  • Use environment variables for wallet
  • Enable rate limiting

Example:

Max Age: 300  // 5 minutes

Networks

Devnet (Testing):

solana airdrop 2 YOUR_ADDRESS --url devnet

Mainnet (Production):

  • Use real wallet
  • Test on devnet first

Troubleshooting

| Issue | Fix | |-------|-----| | Node not visible | Restart n8n, clear browser cache | | Transaction not found | Wait, check network | | Amount mismatch | Verify exact amount | | Transaction too old | Increase Max Age |

Resources

Requirements

  • n8n: v0.220.0+
  • Node.js: v18+

License

MIT

Support


Star if useful!