Corbits is a hosted facilitator service that streamlines x402 payment processing. By using Corbits’ endpoints, you can offload payment verification and settlement without needing to operate your own facilitator infrastructure.
Prerequisites
Node.js and npm installed
A SKALE Chain endpoint
Basic understanding of x402 protocol
Configuration
Environment Variables
Create a .env file with Corbits configuration:
# Receiver address for the x402 payment
RECEIVING_ADDRESS = 0xAddress_Receiving_Payment
# please don't share your private key with anyone
PRIVATE_KEY = 0xyour_pk
SDK import
Please install the following Viem and Farmeter SDKs created by the Corbits team:
npm install @faremeter/info
npm install @faremeter/middleware
Integration with Corbits
Server Setup
Client Setup
import { serve } from "@hono/node-server" ;
import { Hono } from "hono" ;
import { hono as middleware } from "@faremeter/middleware" ;
import { evm } from "@faremeter/info" ;
import "dotenv/config" ;
const app = new Hono ();
const receiver_address = process . env . RECEIVING_ADDRESS || "0xsome_default_address" ;
const facilitator = "https://facilitator.corbits.dev" ;
const paywalledMiddleware = await middleware . createMiddleware ({
facilitatorURL: facilitator ,
accepts: [
evm . x402Exact ({
network: "eip155:324705682" ,
asset: "USDC" ,
amount: "1000" , // $0.0001 in USDC base units
payTo: receiver_address ,
}),
],
});
app . get ( "/api/free" , ( c ) => {
return c . json ({
type: "free" ,
message: "This is free data that does not require payment" ,
timestamp: new Date (). toISOString (),
data: {
temperature: 72 ,
humidity: 45 ,
conditions: "Sunny" ,
},
});
});
// Premium endpoint with payment required
app . get ( "/api/premium" , paywalledMiddleware , ( c ) => {
return c . json ({
type: "paid" ,
message: "This is is a paid data that does require x402 payment" ,
timestamp: new Date (). toISOString (),
data: {
temperature: 72 ,
humidity: 45 ,
conditions: "Sunny" ,
},
});
});
serve ( app , ( info ) => {
console . log ( `Listening on http://localhost: ${ info . port } ` );
});
import { createLocalWallet } from "@faremeter/wallet-evm" ;
import { createPaymentHandler } from "@faremeter/payment-evm/exact" ;
import { wrap as wrapFetch } from "@faremeter/fetch" ;
import { skaleBaseSepoliaTestnet } from "viem/chains" ;
import "dotenv/config" ;
const pk = process . env . PRIVATE_KEY
if ( ! pk ) {
throw new Error ( "PRIVATE_KEY must be set in your environment" );
}
const url = `http://localhost:3000/api/premium` ;
const wallet = await createLocalWallet ( skaleBaseSepoliaTestnet , pk );
const fetchWithPayer = wrapFetch ( fetch , {
handlers: [ createPaymentHandler ( wallet )],
});
const response = await fetchWithPayer ( url );
if ( response . ok ) {
const data = await response . json ();
console . log ( "Response data:" , data );
} else {
console . error ( `Error: ${ response . statusText } ` );
}
Troubleshooting
Connection Issues
If you cannot connect to Corbits:
Verify the facilitator URL is correct
Check network connectivity
Ensure API credentials are valid
Review firewall settings
Payment Failures
Common causes and solutions:
Issue Solution Invalid signature Verify wallet configuration and signing Insufficient balance Ensure payer has enough tokens Network mismatch Check chain ID matches configuration Expired authorization Increase maxTimeoutSeconds
Next Steps
SKALE Supported Facilitators Alternative facilitator with advanced features
Run Your Own Deploy your own facilitator infrastructure
Accept Payments Protect endpoints with payment middleware
Make Payments Build clients that handle x402 payments
Resources
This entity — Corbits — is deployed and activley supporting SKALE. These are 3rd party services that may have their own terms and conditions and privacy polices. Use these services at your own risk. AI and agents is a highly experimental space; the 3rd party software solutions may have bugs or be unaudited. You and your agents and your customers use all 3rd party services chosen at your own risk and per their terms.