Facilitator
The Nexus Facilitator is the core payment processing engine that handles blockchain transactions, payment verification, and settlement.
It uses your own facilitator server wallet to settle payments and receive funds.
How It Works
Getting Started
The Nexus Facilitator is available at:
Authentication
All requests to the Facilitator require authentication using your wallet secret:
You can obtain your wallet secret from the Nexus Dashboard under your account settings.
Available Endpoints
The Facilitator provides the following endpoints:
/verify- Verify a payment without settling it/settle- Verify and settle a payment/list- List all endpoints and their pricing/supported- Get supported chains and tokens
Integration Methods
There are two main ways to integrate the Nexus Facilitator into your API:
Method 1: Using settlePayment() (recommended)
The settlePayment() helper function provides a simple way to verify and settle payments anywhere in your endpoints or middleware.
Installation
Usage
Parameters
resourceUrl: The full URL of your API endpoint that requires paymentmethod: HTTP method (GET, POST, PUT, etc.)paymentData: Payment information from thex-paymentrequest headerpayTo: Your facilitator wallet address that will settle and receive the paymentnetwork: The blockchain network to use (e.g.,base-sepoliaoreip155:<CHAIN_ID>for any EIP-155 chain)price: Price in USD format (e.g.,"$0.10") or custom token amount. Example:facilitator: The configured facilitator instance
Return Value
The settlePayment() function returns an object with:
status: HTTP status code (200 for success, 402 for payment required, etc.)responseBody: Response body (error details or payment instructions)responseHeaders: Response headers (including payment challenge headers)
Method 2: Using X402 Middleware Libraries
The Nexus Facilitator is compatible with existing X402 middleware libraries, making it easy to add payments to your API with minimal code changes.
Keep in mind that some chains and tokens are not supported by all middleware libraries.
Supported Middleware
x402-hono- For Hono frameworkx402-express- For Express.jsx402-next- For Next.js- or any other X402-compatible middleware
Example with x402-hono
When to Use the Facilitator
Use the Facilitator when you want to:
- Integrate payments directly into your existing API code
- Have full control over payment logic and flow
- Build custom middleware or authentication layers
- Implement complex payment conditions or business logic
Use the Nexus Router when you want to:
- Quickly add payments to existing APIs without code changes
- Use a hosted solution for payment handling
- Benefit from automatic request forwarding and caching
Next Steps
- Explore the Nexus Dashboard to manage your API keys and view transaction history
- Learn about the Nexus Router for hosted payment solutions
- Check out building apps with Nexus to integrate payments into your frontend