Pocket node Mock icon

Pocket node Mock

Mock server for HTTP 402 Payment Required (x402 protocol)

Overview

This node is designed to interact with the x402 payment protocol on the Solana blockchain. It supports two main operations: returning an HTTP 402 Payment Required response to indicate that payment is needed for accessing a resource, and verifying a Solana payment transaction signature to confirm that a payment has been made. This node is useful in scenarios where access control is based on blockchain payments, such as premium content access or pay-per-use APIs.

Use Case Examples

  1. A content provider uses the node to return a 402 response with payment details when a user tries to access premium content without payment.
  2. A developer verifies a Solana transaction signature to confirm that a user has paid the expected amount in USDC before granting access to a service.

Properties

Name Meaning
Transaction Signature Solana transaction signature to verify the payment transaction.
Expected Amount (USDC) The expected payment amount in USDC to verify against the transaction.
Wallet Address (Optional) Optional wallet address to override the default or auto-generated wallet address used for receiving payments.

Output

JSON

  • statusCode - HTTP status code, typically 402 for payment required responses.
  • resource - The resource path for which payment is required.
  • description - Human-readable description of the resource or payment requirement.
  • amount - The amount required or verified in USDC.
  • mimeType - MIME type of the resource response.
  • timeout - Timeout duration in seconds for the payment request.
  • verified - Boolean indicating if the payment verification was successful.
  • signature - The Solana transaction signature that was verified.
  • from - The wallet address from which the payment was sent.
  • to - The recipient wallet address for the payment.
  • error - Any error message encountered during payment verification.

Dependencies

  • x402-server-sdk
  • x402-client-sdk

Troubleshooting

  • If the node throws errors related to missing or invalid credentials, ensure that the API key credential for the payment service is correctly configured.
  • If payment verification fails, check that the transaction signature is correct and corresponds to a transaction on the Solana network.
  • If the wallet address is not provided and auto-generation is used, verify that the generated wallet is valid for the specified network (default is devnet).
  • Timeouts or network errors may occur if the node cannot reach the payment verification service; ensure network connectivity and correct configuration.

Links

  • x402 Protocol Documentation - Official documentation for the x402 payment protocol used for blockchain-based payment verification.
  • Solana Developer Resources - Resources and documentation for developing on the Solana blockchain, relevant for understanding transaction signatures and wallets.

Discussion