기술 문서
개발 문서
x402 프로토콜을 프로젝트에 통합하기 위한 가이드와 레퍼런스입니다.
시작하기
빠른 시작
코드
코드 예제
서버 (Express)
import { paymentMiddleware } from "@x402/express";
// 경로별 결제 요구사항 정의
app.use(paymentMiddleware({
"GET /api/premium": {
price: "$0.01",
network: "base-sepolia",
payTo: "0x...",
description: "Premium API endpoint"
}
}));클라이언트
import { x402Client, wrapFetchWithPayment } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
// 클라이언트 설정 및 EVM 체인 등록
const client = new x402Client();
registerExactEvmScheme(client, { signer: evmWallet });
// fetch를 결제 기능으로 감싸기
const payFetch = wrapFetchWithPayment(fetch, client);
await payFetch("/api/premium");가격 정책 안내
사람: 모든 문서는 사람에게 무료입니다. 브라우저에서 JavaScript 검증을 통해 사람임을 확인합니다.
AI 에이전트: Claude, GPT, Cursor 등 AI 도구가 문서에 접근하면 402 Payment Required 응답을 받고 소액의 USDC를 결제해야 콘텐츠에 접근할 수 있습니다.