Actions2
Overview
This node implements a mock server for the HTTP 402 Payment Required response using the x402 protocol. It is designed to simulate scenarios where access to a resource requires payment, typically in USDC cryptocurrency. The node can either return a 402 response indicating the payment requirement or verify a payment signature. This is useful for developers testing payment-required APIs or integrating payment verification in their workflows. For example, it can be used to protect premium content by requiring a payment before access or to verify that a payment has been made before proceeding.
Use Case Examples
- Returning a 402 response with details about the required payment for accessing a premium API endpoint.
- Verifying a Solana transaction signature to confirm a payment of a specified amount.
Properties
| Name | Meaning |
|---|---|
| Description | Human-readable description of the resource, e.g., 'Premium content access'. |
| Amount (USDC) | Amount required in USDC for accessing the resource, e.g., '0.01' for one cent. |
| MIME Type | MIME type of the resource response, e.g., 'application/json'. |
| Timeout (seconds) | Maximum timeout in seconds for the payment requirement. |
| Wallet Address (Optional) | Optional override for the wallet address to receive payments. If empty, a wallet address is auto-generated randomly. |
Output
JSON
statusCode- HTTP status code, always 402 for payment required response.resource- The resource path that requires payment.description- Description of the resource or payment requirement.amount- Amount verified from the payment (only for verifyPayment operation).mimeType- MIME type of the response.timeout- Timeout in seconds for the payment requirement.verified- Boolean indicating if the payment signature verification was successful (only for verifyPayment operation).signature- The Solana transaction signature provided for verification (only for verifyPayment operation).from- Sender wallet address of the payment (only for verifyPayment operation).to- Recipient wallet address of the payment (only for verifyPayment operation).error- Error message if verification failed (only for verifyPayment operation).
Dependencies
- x402-server-sdk
- x402-client-sdk
Troubleshooting
- If the wallet address is not provided, the node auto-generates one. Ensure the generated wallet is valid for your network (default is devnet).
- Errors during payment verification may occur if the signature is invalid or the expected amount does not match the actual payment. Verify the signature and amount inputs.
- If the node throws credential errors, ensure the API key credential for the Pocket Node API is correctly configured and accessible.
Links
- x402 Protocol Documentation - Official documentation for the x402 payment protocol used for HTTP 402 Payment Required responses.
- Solana Documentation - Documentation for Solana blockchain, relevant for payment signature verification.