Skip to main content

Prerequisites

  • Python 3.10+
  • A wallet with USDC on Base (+ small ETH for gas)
  • For testnet: use base-sepolia with test USDC

Install the SDK

pip install xenarch[agent]

Configure your wallet

The SDK loads wallet configuration from environment variables or ~/.xenarch/wallet.json.
export XENARCH_PRIVATE_KEY="0xYOUR_PRIVATE_KEY"
export XENARCH_NETWORK="base"           # or base-sepolia for testnet
export XENARCH_RPC_URL="https://mainnet.base.org"

Pay for gated content

from xenarch.agent_client import check_gate, verify_payment
from xenarch.payment import execute_payment
from xenarch.wallet import load_wallet_or_create

wallet = load_wallet_or_create()

# 1. Check if the URL has a payment gate
gate = check_gate("https://example.com/premium")
if not gate:
    print("No gate — content is free")
else:
    print(f"Price: ${gate.price_usd} USDC")

    # 2. Pay on-chain
    result = execute_payment(
        wallet=wallet,
        splitter_address=gate.splitter,
        collector_address=gate.collector,
        price_usd=gate.price_usd,
    )
    print(f"TX: {result.tx_hash}")

    # 3. Verify and get access token
    verification = verify_payment(gate.verify_url, result.tx_hash)
    token = verification["access_token"]

    # 4. Fetch content with token
    import httpx
    resp = httpx.get(
        "https://example.com/premium",
        headers={"Authorization": f"Bearer {token}"},
    )
    print(resp.text)

Alternative: use the MCP server

If you’re using Claude Desktop or Claude Code, add Xenarch as an MCP server — no code required:
claude mcp add xenarch -- npx @xenarch/agent-mcp
Then ask Claude: “Check if example.com has a paywall and pay for access.” See MCP installation for full setup.

Alternative: use LangChain or CrewAI

pip install xenarch[agent,langchain]
from xenarch.tools.langchain import CheckGateTool, PayTool, GetHistoryTool
tools = [CheckGateTool(), PayTool(), GetHistoryTool()]
See the LangChain integration guide.

Testnet

For testing without real funds, use Base Sepolia:
export XENARCH_NETWORK="base-sepolia"
export XENARCH_RPC_URL="https://sepolia.base.org"
The testnet uses a mock USDC contract (0xc5aDdd66Da733101A5468857Aa3C6689Af9d1DDc) where anyone can mint tokens.