Documentation Index
Fetch the complete documentation index at: https://docs.xenarch.com/llms.txt
Use this file to discover all available pages before exploring further.
Installation
npm install @xenarch/core
Published on npm. Used internally by the MCP server and CLI.
Configuration
import { loadConfig, createSigner } from "@xenarch/core";
const { config } = await loadConfig();
const signer = createSigner(config);
console.log(config.network); // "base" or "base-sepolia"
Config loading priority:
- Environment variables (
XENARCH_PRIVATE_KEY, XENARCH_RPC_URL, etc.)
~/.xenarch/config.json
~/.xenarch/wallet.json
- Auto-generate wallet on first use
Gate checking
import { fetchGate, fetchGateByDomain } from "@xenarch/core";
// Check by URL (HTTP request, looks for 402)
const result = await fetchGate("https://example.com/premium");
if (result.gate) {
console.log(result.gate.price_usd); // "0.003"
}
// Check by domain (platform API)
const gate = await fetchGateByDomain(
"https://xenarch.dev",
"example.com"
);
Payment execution
import { executePayment, verifyPayment } from "@xenarch/core";
// Execute USDC payment on Base
const result = await executePayment(gate, signer, usdcAddress);
console.log(result.txHash); // "0x..."
console.log(result.blockNumber); // 28451023
// Verify and get access token
const { access_token, expires_at } = await verifyPayment(
gate.verify_url,
result.txHash
);
Payment history
import { getPaymentHistory } from "@xenarch/core";
const history = await getPaymentHistory(
"https://xenarch.dev",
walletAddress,
{ domain: "example.com", limit: 10 }
);
Types
interface XenarchConfig {
privateKey: string;
rpcUrl: string;
apiBase: string;
network: "base" | "base-sepolia";
autoApproveMaxUsd?: number;
allowedDomains?: string[];
blockedDomains?: string[];
}
interface GateResponse {
xenarch: boolean;
gate_id: string;
price_usd: string;
splitter: string;
collector: string;
network: string;
asset: string;
protocol: string;
verify_url: string;
expires: string;
}
interface PaymentResult {
txHash: string;
blockNumber: number;
}
interface PaymentHistoryItem {
url: string;
domain: string;
amount_usd: string;
tx_hash: string;
paid_at: string;
}
Contract constants
// Base Mainnet
const USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
const SPLITTER_MAINNET = "0xC6D3a6B6fcCD6319432CDB72819cf317E88662ae";
// Base Sepolia
const SPLITTER_SEPOLIA = "0x7ecfe8f83eab6ba170063d1f1fe7c33695a9ce1d";
const MOCK_USDC_SEPOLIA = "0xc5aDdd66Da733101A5468857Aa3C6689Af9d1DDc";