Quick Start Guide
Get started quickly with BlockEden.xyz's x402 facilitator service as a merchant (server) or a buyer (client).
Coming Soon
BlockEden.xyz's x402 facilitator service is currently in development. This guide shows the planned API structure. Join the waitlist for early access.
Overviewโ
This guide will help you:
- Merchants (Servers): Protect your APIs and content with x402 payment requirements
- Buyers (Clients): Enable your applications and AI agents to automatically pay for protected resources
Prerequisitesโ
Before you begin, you'll need:
- BlockEden.xyz API Key: Sign up at blockeden.xyz/dash
- Wallet Setup: A wallet with USDC on supported networks (Sui recommended)
- Node.js 18+ or Python 3.8+ (depending on your stack)
For Servers (Merchants)โ
Installationโ
- TypeScript
- Python
npm install @blockeden/x402-sdk
# or
yarn add @blockeden/x402-sdk
pip install blockeden-x402
Basic Server Setupโ
- TypeScript (Express)
- TypeScript (Hono)
- Python (FastAPI)
- Python (Flask)
import express from 'express';
import { X402Middleware } from '@blockeden/x402-sdk';
const app = express();
// Configure x402 middleware
const x402 = X402Middleware({
  apiKey: process.env.BLOCKEDEN_API_KEY,
  facilitatorUrl: 'https://x402.blockeden.xyz',
  network: 'sui', // Default network
  token: 'USDC',
});
// Protect your endpoints with x402
app.get('/api/premium/data',
  x402.require({
    amount: '0.01', // 1 cent in USDC
    network: 'sui',
  }),
  (req, res) => {
    // Payment verified - deliver content
    res.json({
      data: 'Your premium content here',
      payment: {
        txHash: req.x402.txHash,
        amount: req.x402.amount,
        network: req.x402.network,
      }
    });
  }
);
app.listen(3000, () => {
  console.log('Server running on http://localhost:3000');
});
import { Hono } from 'hono';
import { x402Middleware } from '@blockeden/x402-sdk/hono';
const app = new Hono();
// Configure x402 middleware
app.use('/api/premium/*', x402Middleware({
  apiKey: process.env.BLOCKEDEN_API_KEY,
  facilitatorUrl: 'https://x402.blockeden.xyz',
  network: 'sui',
  token: 'USDC',
  amount: '0.01',
}));
app.get('/api/premium/data', (c) => {
  const payment = c.get('x402');
  return c.json({
    data: 'Your premium content here',
    payment: {
      txHash: payment.txHash,
      amount: payment.amount,
    }
  });
});
export default app;
from fastapi import FastAPI, Depends
from blockeden_x402 import X402Middleware, X402Payment
app = FastAPI()
# Configure x402 middleware
x402 = X402Middleware(
    api_key=os.environ["BLOCKEDEN_API_KEY"],
    facilitator_url="https://x402.blockeden.xyz",
    network="sui",
    token="USDC",
)
@app.get("/api/premium/data")
async def get_premium_data(
    payment: X402Payment = Depends(x402.require(amount="0.01"))
):
    """Protected endpoint requiring 0.01 USDC payment"""
    return {
        "data": "Your premium content here",
        "payment": {
            "tx_hash": payment.tx_hash,
            "amount": payment.amount,
            "network": payment.network,
        }
    }
if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)
from flask import Flask, jsonify
from blockeden_x402 import X402Middleware
app = Flask(__name__)
# Configure x402 middleware
x402 = X402Middleware(
    api_key=os.environ["BLOCKEDEN_API_KEY"],
    facilitator_url="https://x402.blockeden.xyz",
    network="sui",
    token="USDC",
)
@app.route('/api/premium/data')
@x402.require(amount="0.01")
def get_premium_data(payment):
    """Protected endpoint requiring 0.01 USDC payment"""
    return jsonify({
        "data": "Your premium content here",
        "payment": {
            "tx_hash": payment.tx_hash,
            "amount": payment.amount,
            "network": payment.network,
        }
    })
if __name__ == '__main__':
    app.run(debug=True, port=8000)
How Server Middleware Worksโ
- Request arrives without payment โ Middleware returns 402 Payment Requiredwith payment details
- Request arrives with payment โ Middleware verifies signature with BlockEden.xyz facilitator
- Payment verified โ Request proceeds to your handler with payment details attached
- Verification fails โ Returns 402 Payment Requiredwith error details
For Clients (Buyers)โ
Installationโ
- TypeScript
- Python
npm install @blockeden/x402-client
# or
yarn add @blockeden/x402-client
pip install blockeden-x402-client
Basic Client Setupโ
- TypeScript (Fetch)
- TypeScript (Axios)
- Python (httpx)
- Python (requests)
import { X402Client } from '@blockeden/x402-client';
// Initialize client with wallet
const client = new X402Client({
  privateKey: process.env.WALLET_PRIVATE_KEY,
  network: 'sui',
  facilitatorUrl: 'https://x402.blockeden.xyz',
});
// Fetch protected resource - payment handled automatically
async function fetchPremiumData() {
  try {
    const response = await client.fetch(
      'https://api.example.com/api/premium/data'
    );
    const data = await response.json();
    console.log('Data:', data);
    console.log('Payment TX:', response.headers.get('X-Payment-Response'));
  } catch (error) {
    console.error('Request failed:', error);
  }
}
fetchPremiumData();
import axios from 'axios';
import { createX402Interceptor } from '@blockeden/x402-client';
// Create axios instance with x402 interceptor
const api = axios.create({
  baseURL: 'https://api.example.com',
});
// Add x402 payment interceptor
createX402Interceptor(api, {
  privateKey: process.env.WALLET_PRIVATE_KEY,
  network: 'sui',
  facilitatorUrl: 'https://x402.blockeden.xyz',
});
// Make requests normally - payments handled automatically
async function fetchPremiumData() {
  try {
    const response = await api.get('/api/premium/data');
    console.log('Data:', response.data);
  } catch (error) {
    console.error('Request failed:', error);
  }
}
fetchPremiumData();
import os
from blockeden_x402_client import X402Client
# Initialize client with wallet
client = X402Client(
    private_key=os.environ["WALLET_PRIVATE_KEY"],
    network="sui",
    facilitator_url="https://x402.blockeden.xyz",
)
# Fetch protected resource - payment handled automatically
async def fetch_premium_data():
    response = await client.get(
        "https://api.example.com/api/premium/data"
    )
    data = response.json()
    print(f"Data: {data}")
    print(f"Payment TX: {response.headers.get('X-Payment-Response')}")
# Run async function
import asyncio
asyncio.run(fetch_premium_data())
import os
import requests
from blockeden_x402_client import X402Session
# Create session with x402 support
session = X402Session(
    private_key=os.environ["WALLET_PRIVATE_KEY"],
    network="sui",
    facilitator_url="https://x402.blockeden.xyz",
)
# Make requests normally - payments handled automatically
def fetch_premium_data():
    response = session.get(
        "https://api.example.com/api/premium/data"
    )
    data = response.json()
    print(f"Data: {data}")
    print(f"Payment TX: {response.headers.get('X-Payment-Response')}")
fetch_premium_data()
How Client Library Worksโ
- Makes initial request to protected endpoint
- Receives 402 response with payment requirements
- Signs payment authorization using your wallet
- Retries request with X-Paymentheader containing signature
- Receives content after payment verification
AI Agent Integrationโ
Claude MCP (Model Context Protocol)โ
import { X402MCPServer } from '@blockeden/x402-mcp';
const server = new X402MCPServer({
  wallet: process.env.AGENT_WALLET_PRIVATE_KEY,
  network: 'sui',
  facilitatorUrl: 'https://x402.blockeden.xyz',
  spendingLimit: {
    daily: '10.00', // Max $10 per day
    perTransaction: '1.00', // Max $1 per transaction
  }
});
// Register with Claude
server.start();
Now Claude can autonomously discover and pay for x402-protected services.
LangChain Integrationโ
from langchain.tools import Tool
from blockeden_x402_client import X402Client
# Create x402-enabled HTTP client for agent
client = X402Client(
    private_key=os.environ["AGENT_WALLET_PRIVATE_KEY"],
    network="sui",
    facilitator_url="https://x402.blockeden.xyz",
)
# Create tool for LangChain agent
x402_fetch_tool = Tool(
    name="x402_fetch",
    description="Fetch data from x402-protected APIs with automatic payment",
    func=lambda url: client.get(url).json()
)
# Add to your agent's tools
agent_tools.append(x402_fetch_tool)
Facilitator Configurationโ
BlockEden.xyz Facilitatorโ
Facilitator URL: https://x402.blockeden.xyz
Available Endpoints:
- /verify- Verify payment signature
- /settle- Execute on-chain settlement
- /list- List supported networks and tokens
Environment Variablesโ
# Server configuration
BLOCKEDEN_API_KEY=your_api_key_here
BLOCKEDEN_X402_FACILITATOR=https://x402.blockeden.xyz
# Client configuration
WALLET_PRIVATE_KEY=your_private_key_here
X402_NETWORK=sui
Supported Networksโ
BlockEden.xyz's x402 facilitator supports the following networks:
| Network | Chain ID | Token | Status | 
|---|---|---|---|
| Sui Mainnet | sui | USDC | ๐ข Primary | 
| Sui Testnet | sui-testnet | USDC | ๐ข Active | 
| Base Mainnet | base | USDC | ๐ก Coming Soon | 
| Base Sepolia | base-sepolia | USDC | ๐ก Coming Soon | 
| Ethereum | ethereum | USDC | ๐ก Coming Soon | 
| Polygon | polygon | USDC |