Skip to main content
This guide walks you through setting up and running an x402 facilitator using the Faremeter SDK. We’ll focus on the minimal configuration needed to get a basic facilitator running on the SKALE Base Sepolia Testnet.

Prerequisites

Ensure you have Bun v1.3.1 or newer installed on your machine. You’ll also need a funded wallet with SKALE Credits (CRED) and AxiosUSD tokens on SKALE Base Sepolia Testnet. If you do not have a private key, you can create one using MetaMask or generate one with the Cast tool from Foundry.
cast wallet new

Step 1: Clone and Setup the Facilitator Project

Fork and clone your fork of the facilitator project and install dependencies:
# git clone https://github.com/thegreataxios/facilitator.git
git clone git@github.com:<your-username>/facilitator.git
cd facilitator
bun install
The facilitator project is pre-configured for SKALE Base Sepolia Testnet with AxiosUSD token support.

Step 2: Set Up Your Wallet

Add your private key to the .env file:
EVM_PRIVATE_KEY=0x_your_private_key_here

Step 3: Start the Facilitator

Run the facilitator using Bun’s development mode:
bun run dev
Expected output:
[INFO] facilitator Starting server on http://localhost:3000
[INFO] facilitator Facilitator ready - chains: 1, tokens: 1

Step 4: Verify the Facilitator is Running

Check that the facilitator is working correctly:
curl http://localhost:3000/healthz
Expected output:
{
  "timestamp": 1703123456789,
  "uptime": 123.456,
  "status": "healthy"
}

How It Works

The facilitator acts as the payment processor in the x402 protocol:
  1. Client Request: A buyer makes a request to a paid API endpoint
  2. Payment Required: Server responds with 402 Payment Required and payment details
  3. Payment Authorization: Client signs a payment authorization using EIP-3009
  4. Payment Submission: Client submits the signed authorization to the facilitator
  5. Payment Processing: Facilitator validates and executes the transfer (gasless for clients)
  6. Access Granted: Server grants access to the protected resource

Configuration Options

The facilitator is pre-configured for SKALE Base Sepolia Testnet with Axios USD token support. Key configuration details:
  • Chain ID: 2140350733 (SKALE Base Sepolia Testnet)
  • RPC URL: https://base-sepolia-testnet.skalenodes.com/v1/basic-defiant-hadar
  • Token: Axios USD at 0x61a26022927096f444994dA1e53F0FD9487EAfcf
  • Forwarder: Same address (EIP-3009 compliant for gasless transfers)

Error Handling

Common issues and solutions:
  1. “EVM_PRIVATE_KEY is not set”
    • Ensure your .env file exists and contains the private key
    • Verify the key starts with 0x and is 64 characters long
  2. “EVM_PRIVATE_KEY is not a valid hex string”
    • Check that the private key contains only valid hexadecimal characters
    • Ensure no extra spaces or characters are present
  3. “Insufficient funds for gas”
    • Fund your wallet with SKALE Credits (CRED) from the faucet
    • The facilitator needs CRED to pay for transaction gas fees
  4. “Execution reverted”
    • Ensure your wallet has sufficient AxiosUSD balance
    • Verify the token contract address is correct

Next Steps

Once your facilitator is running: