Web3 域名开发者与 SDK
集成正向与反向解析、零依赖 @web3domain/sdk、使用 Web3DomainApp 登录(OIDC + SIWE)及 Base Mainnet USDC x402 支付。
人类 dApp 与 AI 代理的复制粘贴集成
秒级解析域名至 ERC-6551 金库,反向解析钱包,验证 AI Agent Passport,检查 x402 USDC 支付条款。
解析域名 → EVM 与金库
GET /api/v1/resolve/<name>
反向解析钱包 → 域名
GET /api/v1/reverse/<address>
验证代理护照与 x402
GET /api/v1/agent/<name>/manifest.json
# 1. Resolve Web3 Domain -> EVM Owner Address & ERC-6551 Smart Vault curl -s "https://web3domain.app/api/v1/resolve/agent.tld" # 2. Reverse Resolve 0x Wallet -> Primary Web3 Domain curl -s "https://web3domain.app/api/v1/reverse/0xYOUR_EVM_WALLET_ADDRESS" # 3. Verify AI Agent Passport (KYA), Trust Score & x402 USDC Endpoint curl -s "https://web3domain.app/api/v1/agent/agent.tld/manifest.json" curl -s "https://web3domain.app/api/v1/trust/agent.tld/" curl -i "https://web3domain.app/api/v1/x402/agent.tld/resource-slug/"
import { createPublicClient, http } from "viem";
import { base } from "viem/chains";
const BASE_API = "https://web3domain.app";
const client = createPublicClient({ chain: base, transport: http("https://mainnet.base.org") });
// 1. Resolve Domain -> EVM Wallet & Deterministic ERC-6551 Smart Vault
const resolved = await fetch(`${BASE_API}/api/v1/resolve/agent.tld`).then((r) => r.json());
const vaultBalanceWei = await client.getBalance({ address: resolved.erc6551_vault || resolved.owner });
// 2. Reverse Resolve 0x Wallet -> Primary Web3 Domain
const primary = await fetch(`${BASE_API}/api/v1/reverse/0xYOUR_EVM_WALLET_ADDRESS`).then((r) => r.json());
// 3. Verify AI Agent Passport (KYA) & Inspect x402 Base USDC Payment Terms
const passport = await fetch(`${BASE_API}/api/v1/agent/agent.tld/manifest.json`).then((r) => r.json());
const x402Challenge = await fetch(`${BASE_API}/api/v1/x402/agent.tld/resource-slug/`).then((r) => r.json());
console.log({ resolved, vaultBalanceWei, primary, passport, x402Challenge });
import requests
BASE_API = "https://web3domain.app"
# 1. Resolve Web3 Domain -> EVM Address & ERC-6551 Smart Vault
resolved = requests.get(f"{BASE_API}/api/v1/resolve/agent.tld", timeout=10).json()
# 2. Reverse Resolve Wallet -> Primary Web3 Domain
primary = requests.get(f"{BASE_API}/api/v1/reverse/0xYOUR_EVM_WALLET_ADDRESS", timeout=10).json()
# 3. Verify AI Agent Passport, Trust Score & x402 USDC Challenge
passport = requests.get(f"{BASE_API}/api/v1/agent/agent.tld/manifest.json", timeout=10).json()
trust = requests.get(f"{BASE_API}/api/v1/trust/agent.tld/", timeout=10).json()
x402_res = requests.get(f"{BASE_API}/api/v1/x402/agent.tld/resource-slug/", timeout=10)
if x402_res.status_code == 402:
terms = x402_res.json() # payTo, Base USDC contract (6 decimals), amountBaseUnits
# Settle Base Mainnet USDC on-chain, then retry with X-PAYMENT-TX header:
# unlocked = requests.get(url, headers={"X-PAYMENT-TX": "0xYOUR_BASE_TX_HASH"}).json()
print("x402 payment required:", terms)
实时交互式 API 测试工具
SDK & Integration Snippets
import { Web3DomainClient } from "@web3domain/sdk";
const client = new Web3DomainClient({ baseUrl: "https://web3domain.app" });
// 1. Forward resolution (wallets, IPFS, profile, x402 resources)
const domain = await client.resolve("asi");
// 2. Reverse resolution (0x wallet -> Primary Domain)
const primary = await client.reverseResolve("0x91d1E61B6d06Fd7Cf2c53982479341069Ae49c5B");
// 3. Batch reverse resolution (up to 50 items per call)
const batch = await client.batchReverseResolve(["0x91d1E61B6d06Fd7Cf2c53982479341069Ae49c5B"]);
// 4. Verify RS256 OIDC id_token against /.well-known/jwks.json
const claims = await client.verifyIdToken(idToken, { audience: "w3d_your_client_id" });
<a href="https://web3domain.app/oauth/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=https://yourapp.com/callback&response_type=code&scope=openid+profile+wallet&state=random_csrf_token">
Sign in with Web3DomainApp
</a>
// Token Exchange (POST https://web3domain.app/oauth/token)
// grant_type=authorization_code&code=CODE&client_id=ID&client_secret=SECRET&redirect_uri=...
// Returns: { access_token, id_token (RS256), token_type: "Bearer", expires_in: 3600 }
import requests
# Step 1: Request paid agent resource -> receives HTTP 402 + Base Mainnet USDC challenge
url = "https://web3domain.app/api/v1/x402/asi/premium-feed/"
r = requests.get(url)
if r.status_code == 402:
challenge = r.json() # payTo, tokenAddress (Base USDC), amountBaseUnits (6 decimals)
# Step 2: Execute ERC-20 transfer on Base Mainnet (Chain ID 8453) & retry with X-PAYMENT-TX
unlocked = requests.get(url, headers={"X-PAYMENT-TX": "0xYOUR_CONFIRMED_USDC_TX_HASH"})
print(unlocked.json())
# Forward Resolution
curl https://web3domain.app/api/v1/resolve/asi
# Reverse Resolution (Primary Name)
curl https://web3domain.app/api/v1/reverse/0x91d1E61B6d06Fd7Cf2c53982479341069Ae49c5B
# Batch Resolve (max 50 items)
curl -X POST https://web3domain.app/api/v1/resolve/batch \
-H "Content-Type: application/json" \
-d '{"addresses":["0x91d1E61B6d06Fd7Cf2c53982479341069Ae49c5B"],"domains":["asi"]}'
Resolution & Reverse API
GET /api/v1/resolve/<domain>
GET /api/v1/reverse/<wallet>
POST /api/v1/resolve/batch
GET /api/v1/ccip/{sender}/{data}.json
OIDC / OAuth 2.0 + SIWE
GET /.well-known/openid-configuration
GET /.well-known/jwks.json
GET /oauth/authorize · POST /oauth/token
Base USDC & x402 Protocol
POST /api/v1/payments/verify-usdc/
GET /api/v1/x402/<domain>/<slug>/
USDC: 0x833589fC...A02913 (Base 8453)