Okx Dex Trenches
nirholas/three.ws
Read-only on-chain research for pump.fun and other meme-token launchpads (Solana / BSC / X Layer / TRON).
タスクごとのバジェット、支出コントロール、ノンカストディアルウォレットを備えた x402 決済実行を AI エージェントに追加します。agentwallet-sdk を通じて Base を、OKX Payments / OKX エージェント決済プロトコルを通じて X Layer を、アップストリームの x402 パッケージとファシリテーターベースの決済を通じて Solana…
$ npx skills add affaan-m/ECC --skill agent-payment-x402 -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install affaan-m/ECC agent-payment-x402 --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .claude/skills && cp -r skills-src/docs/ja-JP/skills/agent-payment-x402 .claude/skills/agent-payment-x402 && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "agent-payment-x402" agent skill from https://github.com/affaan-m/ECC/tree/main/docs/ja-JP/skills/agent-payment-x402 into .claude/skills/agent-payment-x402/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "agent-payment-x402", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/affaan-m/ECC/tree/main/docs/ja-JP/skills/agent-payment-x402Type this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add affaan-m/ECC --skill agent-payment-x402 -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install affaan-m/ECC agent-payment-x402 --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .agents/skills && cp -r skills-src/docs/ja-JP/skills/agent-payment-x402 .agents/skills/agent-payment-x402 && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "agent-payment-x402" agent skill from https://github.com/affaan-m/ECC/tree/main/docs/ja-JP/skills/agent-payment-x402 into .agents/skills/agent-payment-x402/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "agent-payment-x402", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add affaan-m/ECC --skill agent-payment-x402 -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install affaan-m/ECC agent-payment-x402 --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/docs/ja-JP/skills/agent-payment-x402 .cursor/skills/agent-payment-x402 && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "agent-payment-x402" agent skill from https://github.com/affaan-m/ECC/tree/main/docs/ja-JP/skills/agent-payment-x402 into .cursor/skills/agent-payment-x402/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "agent-payment-x402", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/affaan-m/ECC.git --path docs/ja-JP/skills/agent-payment-x402--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add affaan-m/ECC --skill agent-payment-x402 -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install affaan-m/ECC agent-payment-x402 --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/docs/ja-JP/skills/agent-payment-x402 .gemini/skills/agent-payment-x402 && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "agent-payment-x402" agent skill from https://github.com/affaan-m/ECC/tree/main/docs/ja-JP/skills/agent-payment-x402 into .gemini/skills/agent-payment-x402/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "agent-payment-x402", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install affaan-m/ECC agent-payment-x402Installs for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add affaan-m/ECC --skill agent-payment-x402 -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .github/skills && cp -r skills-src/docs/ja-JP/skills/agent-payment-x402 .github/skills/agent-payment-x402 && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "agent-payment-x402" agent skill from https://github.com/affaan-m/ECC/tree/main/docs/ja-JP/skills/agent-payment-x402 into .github/skills/agent-payment-x402/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "agent-payment-x402", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add affaan-m/ECC --skill agent-payment-x402 -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install affaan-m/ECC agent-payment-x402 --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/docs/ja-JP/skills/agent-payment-x402 .opencode/skills/agent-payment-x402 && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "agent-payment-x402" agent skill from https://github.com/affaan-m/ECC/tree/main/docs/ja-JP/skills/agent-payment-x402 into .opencode/skills/agent-payment-x402/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "agent-payment-x402", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
agent-payment-x402タスクごとのバジェット、支出コントロール、ノンカストディアルウォレットを備えた x402 決済実行を AI エージェントに追加します。agentwallet-sdk を通じて Base を、OKX Payments / OKX エージェント決済プロトコルを通じて X Layer を、アップストリームの x402 パッケージとファシリテーターベースの決済を通じて Solana…
Agent Payment X402 is an agent skill from affaan-m/ECC. タスクごとのバジェット、支出コントロール、ノンカストディアルウォレットを備えた x402 決済実行を AI エージェントに追加します。agentwallet-sdk を通じて Base を、OKX Payments / OKX エージェント決済プロトコルを通じて X Layer を、アップストリームの x402 パッケージとファシリテーターベースの決済を通じて Solana とマルチネットワーク EVM をサポートします。
Its SKILL.md is about 5.4k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
It sits in Backend & APIs, covering Smart contracts. It works with x402, OKX, Solana and Model Context Protocol. The repository describes itself as: The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond. The licence is MIT.
4 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit 4eb71d9. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Shell commands in SKILL.md call:
curljqnpmFrom the folder's file list and the shell code blocks in SKILL.md.
Hosts in commands or code, which the agent is likely to contact:
raw.githubusercontent.comapi.cdp.coinbase.comfacilitator.payai.networkapi.mainnet-beta.solana.comAlso links to:
github.comdocs.x402.orgx402.orgpay.shnpmjs.comweb3.okx.comFrom URLs in SKILL.md, links to its own repository left out.
Names these keys or tokens, usually read from environment variables:
WALLET_PRIVATE_KEYEVM_PRIVATE_KEYSVM_PRIVATE_KEYFrom names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Agent Payment X402 loads about 5.4k tokens when it runs. Until then it costs about 58 tokens; SKILL.md has 589 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from affaan-m/ECC at commit 4eb71d9, republished under its MIT licence (© affaan-m). 589 words, ~5,424 tokens.
.claude/skills/agent-payment-x402/SKILL.md (or your agent's skills folder).ポリシーゲートによる決済と組み込みの支出コントロールで AI エージェントを有効化します。x402 HTTP 決済プロトコルと MCP ツールを使用して、カストディアルリスクなしに外部サービス、API、または他のエージェントへの支払いを行えます。
使用する場合:エージェントが API 呼び出しへの支払い、サービスの購入、別のエージェントとの決済、タスクごとの支出制限の強制、またはノンカストディアルウォレットの管理を必要とする場合。cost-aware-llm-pipeline および security-review スキルと自然に組み合わせられます。
エージェントが有料 API へのアクセスを購入するか、他者にアクセスを課金するかに基づいて統合パスを選択します:
| ニーズ | 推奨パス |
|---|---|
| エージェントが Base または他の agentwallet 対応チェーンの 402 ゲート API に支払う | 厳格な支出ポリシーで agentwallet-sdk を MCP 決済サーバーとして使用 |
| エージェントが X Layer の 402 ゲート API に支払う | okx/onchainos-skills の OKX エージェント決済プロトコルを使用;okx-x402-payment は廃止されたレガシーエイリアス |
| エージェントが Solana または他の x402 v2 ネットワークの 402 ゲート API に支払う | エージェントの HTTP クライアントをアップストリームの @x402/fetch または @x402/axios パッケージでラップし、EVM/SVM スキームを登録する;リソースサーバーのファシリテーターが検証・決済する |
| API が Solana または複数ネットワークでエージェントに課金する(TypeScript、Python、または Go) | x402-foundation/x402 のアップストリーム x402 ミドルウェアを使用 — TypeScript は @x402/express、@x402/hono、@x402/next、または @x402/fastify、Python は x402、Go は github.com/x402-foundation/x402/go/v2 |
| TypeScript API がエージェントに課金する | Express、Hono、Fastify、または Next.js 向け OKX Payments TypeScript セラー SDK ドキュメントを使用 |
| Go API がエージェントに課金する | Gin、Echo、または net/http 向け OKX Payments Go セラー SDK ドキュメントを使用 |
| Rust API がエージェントに課金する | Axum 向け OKX Payments Rust セラー SDK ドキュメントを使用 |
| Java API がエージェントに課金する | Spring Boot 2/3、Java EE、または Jakarta 向け OKX Payments Java セラー SDK ドキュメントを使用 |
| Python API がエージェントに課金する | 実装前に現在の OKX Payments リポジトリを確認;Python セラーガイドがない場合がある |
agentwallet-sdk: 本番使用前に現在のネットワークカバレッジをパッケージドキュメントで確認。Base Sepolia が最も安全な開発デフォルト;Base メインネットがオリジナルスキルで説明されている本番パス。eip155:196)と USDT0 決済を対象。決済パッケージとファシリテーターの動作が迅速に変わる可能性があるため、本番コードを生成する前に現在の SDK ドキュメントを取得すること。x402.org ファシリテーターで、テストネット専用(Base Sepolia eip155:84532、Solana デブネット solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1、加えて Stellar、Aptos、Hedera、XRPL の各テストネット)であり、メインネットルート向けではない。メインネット(Solana は solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp)では、自己ファシリテートするか、自前のファシリテーターを運用するか、アップストリームのファシリテーターリストからホスト型を選ぶ — オプション C のファシリテーター比較を参照。本番前にここにハードコードするのではなく、ファシリテーターの /supported エンドポイントでライブカバレッジを確認すること。x402 は HTTP 402(Payment Required)を機械が交渉可能なフローに拡張します。サーバーが 402 を返すと、エージェントの決済ツールが価格を交渉し、バジェットを確認し、トランザクションに署名し、オーケストレーターが設定したポリシーと確認境界内でのみリトライします。
すべての決済ツール呼び出しは SpendingPolicy を強制します:
エージェントは ERC-4337 スマートアカウントを通じて独自のキーを保持します。オーケストレーターが委任前にポリシーを設定し、エージェントは境界内でのみ支出できます。プールされた資金なし、カストディアルリスクなし。
決済層は Claude Code またはエージェントハーネスのセットアップに組み込まれる標準 MCP ツールを公開します。
セキュリティ注意: 常にパッケージバージョンを固定してください。このツールは秘密鍵を管理します — 固定されていない
npxインストールはサプライチェーンリスクをもたらします。
{
"mcpServers": {
"agentpay": {
"command": "npx",
"args": ["agentwallet-sdk@6.0.0"]
}
}
}| ツール | 目的 |
|---|---|
get_balance | エージェントウォレットの残高を確認 |
send_payment | アドレスまたは ENS に支払いを送信 |
check_spending | 残りバジェットを照会 |
list_transactions | すべての支払いの監査証跡 |
注意: 支出ポリシーはエージェントへの委任前にオーケストレーターが設定します — エージェント自体では設定しません。これによりエージェントが独自の支出制限をエスカレーションするのを防ぎます。オーケストレーション層またはタスク前のフックで
set_policy経由でポリシーを設定し、エージェント呼び出し可能ツールとしては設定しないこと。
X Layer x402、マルチパーティ決済(MPP)、セッション決済、チャージ、A2A チャージフロー向けにこのパスを使用します。
バイヤー側エージェントフローの場合:
okx/onchainos-skills リポジトリをインストールまたは参照する。skills/okx-agent-payments-protocol/SKILL.md をディスパッチャーとして使用する。skills/okx-x402-payment/SKILL.md は廃止された互換エイリアスとして扱い、正規スキルとしては扱わない。セラー側 API フローの場合、コードを生成する前に最新の言語固有ガイドを取得する:
| ランタイム | 現在のガイド |
|---|---|
| TypeScript | https://raw.githubusercontent.com/okx/payments/main/typescript/SELLER.md |
| Go | https://raw.githubusercontent.com/okx/payments/main/go/x402/SELLER.md |
| Rust | https://raw.githubusercontent.com/okx/payments/main/rust/x402/SELLER.md |
| Java | https://raw.githubusercontent.com/okx/payments/main/java/SELLER.md |
現在の OKX リポジトリを確認せずに古いドキュメントの例をコピーしないこと。現在の OKX ガイダンスはディスパッチャーとして okx-agent-payments-protocol を使用しており、Java セラードキュメントが利用可能になっています。
エージェントが Solana、Base、またはアップストリームのプロトコル実装がサポートする他のネットワークで支払う(または API が課金する)場合にこのパスを使用します。x402-foundation/x402 の正規 x402 モノレポは活発にメンテナンスされており、クライアントとミドルウェアのパッケージを直接公開しています。オプション A・B と異なり、これは別個の MCP サーバーではありません — エージェント自身の HTTP クライアントをラップし、リソースサーバーが選んだファシリテーターが検証・決済します。
バイヤー側エージェントフローの場合:
古いドキュメントのスニペットをコピーするのではなく、メンテナンスされている examples/typescript/clients(fetch、axios、MCP)の例から始める。
オプション B が OKX フローに要求するのとまったく同様に、最初の有料リクエストの署名または送信の前に明示的なユーザー確認を求める。汎用ツール呼び出しの背後に決済実行を隠さない。
パッケージバージョンを固定する(例:@x402/fetch@2.22.0);アップストリームの全パッケージはロックステップでバージョニングされる。
バジェットはクライアントに登録した PaymentPolicy で強制し、毎回サーバーの実際のチャレンジに対して検査が走るようにする。自分で渡した数値と突き合わせるバジェットは何も証明しない — 金額・アセット・ネットワークはすべてサーバー由来なので、署名が生成される前に 3 つとも検証すること。
受取先と予算のポリシーとは別に、許可するリソースのオリジンを正確に設定する。以下の支払い対応 fetch はすべてリダイレクトを拒否する。セッションの確認には許可オリジン、ネットワーク、資産、受取先、人が読める単位の支出上限を明示し、並行呼び出しは同じ確認結果を共有する。クライアントとポリシーはオーケストレーター内に留める。
import { x402Client, wrapFetchWithPayment } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { ExactSvmScheme } from "@x402/svm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
import { createKeyPairSignerFromBytes } from "@solana/kit";
import { base58 } from "@scure/base";
// Signer keys belong to the ORCHESTRATOR's env — never hardcoded, never agent-writable.
const evmKey = process.env.EVM_PRIVATE_KEY as `0x${string}`;
const svmKey = process.env.SVM_PRIVATE_KEY;
if (!evmKey || !svmKey) {
throw new Error("Signer keys are not set — refusing to start payment client");
}
// One client, both network families: the buyer pays whichever chain the 402 offers.
const client = new x402Client();
client.register("eip155:*", new ExactEvmScheme(privateKeyToAccount(evmKey)));
client.register("solana:*", new ExactSvmScheme(await createKeyPairSignerFromBytes(base58.decode(svmKey))));
// A PaymentPolicy filters the SERVER's payment requirements before any
// signature is created. Returning an empty array means "nothing here is
// acceptable" and the client refuses to pay rather than falling back.
const ALLOWED_NETWORKS = new Set([
"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", // Solana mainnet
"eip155:8453", // Base
]);
const MAX_AMOUNT = 10_000n; // atomic units, 6-decimal USDC: 0.01 USDC per call
const SESSION_CAP = 50_000n; // 0.05 USDC across the whole session
// EVM addresses are case-insensitive, so compare them lowercased. Solana
// addresses are base58 and ARE case-sensitive — never lowercase those, or a
// different account could slip through.
const normalizeAddress = (a: string) => (a.startsWith("0x") ? a.toLowerCase() : a);
const ALLOWED_ASSETS = new Set(
[
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC, Solana mainnet
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC, Base
].map(normalizeAddress),
);
// Who you are willing to pay. Without this, any 402 an agent happens to hit
// can name its own recipient.
const ALLOWED_PAY_TO = new Set(
["7pr7NCaQRz5PEhPy7BAeB3Z72TVkiShhjRyVCN5DA6yC"].map(normalizeAddress),
);
client.registerPolicy((_x402Version, requirements) =>
requirements.filter(r => {
if (!ALLOWED_NETWORKS.has(r.network)) return false; // wrong chain
if (!ALLOWED_ASSETS.has(normalizeAddress(r.asset))) return false; // wrong token
if (!ALLOWED_PAY_TO.has(normalizeAddress(r.payTo))) return false; // wrong recipient
try {
const amount = BigInt(r.amount);
return amount >= 0n && amount <= MAX_AMOUNT; // over budget / negative
} catch {
return false; // unparseable amount
}
}),
);
// The policy sees one challenge at a time, so it cannot enforce a session
// total or ask a human anything. Keep the payment-enabled client private and
// route every paid call through the payOnce boundary below.
// Supply this from your harness — a real prompt, never a stub that returns true.
declare function confirmWithUser(prompt: string): Promise<boolean>;
// Resource authorization is independent of recipient and budget policy.
// The ORCHESTRATOR supplies exact approved HTTPS origins before delegation;
// never populate this set from a server challenge or agent-controlled input.
const ALLOWED_ORIGINS = new Set(["https://api.example.com"]);
function requireAllowedOrigin(url: string): void {
const parsed = new URL(url);
if (!ALLOWED_ORIGINS.has(parsed.origin) || parsed.username || parsed.password) {
throw new Error("Resource origin is not authorized");
}
}
// Both approved assets above are 6-decimal USDC. Update this trusted formatting
// policy along with the asset allowlist if you support other assets/decimals.
const USDC_SCALE = 1_000_000n;
const humanUSDC = (amount: bigint) =>
`${amount / USDC_SCALE}.${(amount % USDC_SCALE).toString().padStart(6, "0").replace(/0+$/, "") || "0"} USDC`;
let sessionSpent = 0n;
let sessionApproval: Promise<boolean> | undefined;
async function payOnce(url: string, init?: RequestInit): Promise<Response> {
requireAllowedOrigin(url); // Before reservation, prompt, fetch, or signature.
// Reserve the worst case the policy allows. Settlement responses do not
// carry an amount, so counting MAX_AMOUNT per call is a deliberate
// over-estimate — it can stop early, never late. Reserve before any await,
// so concurrent calls cannot all pass the check.
if (sessionSpent + MAX_AMOUNT > SESSION_CAP) {
throw new Error("Session budget exhausted — blocked");
}
sessionSpent += MAX_AMOUNT;
// Release the reservation only when no signed payment left this process:
// a declined or failed prompt, a challenge the policy rejected, or a free
// response. Once a signed request is sent it may settle, so keep it counted.
let signedRequestSent = false;
const trackingFetch: typeof fetch = async (input, reqInit) => {
// Override caller options on BOTH the challenge and signed retry. Native
// fetch refuses redirects, so an unauthorized host cannot return a 402
// or receive a payment header via an automatic redirect.
const req = new Request(input, { ...reqInit, redirect: "error" });
requireAllowedOrigin(req.url);
if (req.headers.has("PAYMENT-SIGNATURE") || req.headers.has("X-PAYMENT")) {
signedRequestSent = true;
}
const response = await fetch(req);
// Also fail closed for adapters that expose a redirect response instead.
if (response.redirected || (response.status >= 300 && response.status < 400)) {
throw new Error("Paid request redirects are blocked");
}
return response;
};
try {
// Install one promise before awaiting the prompt. Concurrent calls share
// the same decision, including a decline or failure; never auto-reprompt.
sessionApproval ??= Promise.resolve().then(() => confirmWithUser(
`Allow paid requests to origins: ${[...ALLOWED_ORIGINS].join(", ")}? ` +
`Networks: ${[...ALLOWED_NETWORKS].join(", ")}. ` +
`Assets: ${[...ALLOWED_ASSETS].join(", ")} (6-decimal USDC). ` +
`Recipients (payTo): ${[...ALLOWED_PAY_TO].join(", ")}. ` +
`Per-call cap: ${humanUSDC(MAX_AMOUNT)}; session cap: ${humanUSDC(SESSION_CAP)}.`,
));
if (!await sessionApproval) {
throw new Error("User declined: no payment attempted");
}
return await wrapFetchWithPayment(trackingFetch, client)(url, init);
} finally {
if (!signedRequestSent) sessionSpent -= MAX_AMOUNT;
}
}
const res = await payOnce("https://api.example.com/data", { method: "GET" });ポリシーを登録すると、予算超過の金額、想定外のトークン、未登録のチェーンはすべてフェイルクローズドになる — 候補がすべて除外されるため、createPaymentPayload は署名せずに例外を投げる。デブネット USDC は 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU;開発時のみ ALLOWED_ASSETS に追加すること。ポリシーは敵対的にテストする — 5000000 アトミック単位を要求するチャレンジ、別のミントを提示するチャレンジ、登録していないチェーンのチャレンジを与え、いずれも署名が生成されないことを確認する。exact-SVM スキームではファシリテーターがトランザクション手数料支払者となるため、買い手のウォレットは USDC のみを保有すればよい — ガス用の SOL は不要。
ファシリテーターの選択。 ファシリテーターはリソースサーバーに代わって検証と決済を行うため、これは買い手ではなくリソースサーバーの判断である。委ねる信頼が小さい順に:
| 選択肢 | 適する場面 |
|---|---|
| インプロセスで自己ファシリテート | 決済経路に第三者を入れたくなく、鍵と RPC アクセスを自前で保持できる |
| 自前のファシリテーターを運用 | 同じ制御を複数サービスで共有したい |
x402.org ファシリテーター | 開発・テストネット向け — パッケージのデフォルトでセットアップ不要。アップストリームはメインネットルート向けではないと明記している |
| ホスト型の本番ファシリテーター | インフラを運用せずにメインネット対応が欲しい |
ホスト型を選ぶ場合は、ここに書かれた名前ではなくアップストリームドキュメントのファシリテーターリストから選ぶこと — メンテナンスされており、網羅的ではなく、カバレッジも変わる。執筆時点では Coinbase の CDP(全トランザクションに KYT/OFAC スクリーニング)、PayAI、Corbits、Dexter、Solvador などが掲載され、複数が EVM に加えて Solana メインネットをカバーしている。どれを選ぶ場合も、本番前に /supported エンドポイントでライブカバレッジを確認し、ネットワークを追加したときは再確認すること。
開示: このセクションは、掲載されているファシリテーターの 1 つである PayAI に関わる者が寄稿した。複数ある選択肢の 1 つとして記載しており、上記の自己ホストおよびアップストリームデフォルトのパスを意図的に先に挙げている。
セラー側(API がエージェントに課金する)。 アップストリームのミドルウェアを使用する;1 つのルートで Base と Solana を同時に提示できる(実行可能なバージョンは examples/typescript/servers を参照):
| ランタイム | パッケージ |
|---|---|
| Express / Hono / Next.js / Fastify | @x402/express@2.22.0、@x402/hono@2.22.0、@x402/next@2.22.0、@x402/fastify@2.22.0 |
| Python(FastAPI、Flask) | PyPI の x402 |
Go(Gin、Echo、net/http) | github.com/x402-foundation/x402/go/v2 |
Solana のセラー:payTo アドレスには先に正規のトークンアカウントが必要。 exact-SVM クライアントは findAssociatedTokenPda で payTo の関連トークンアカウント(ATA)を導出してそこに送金するが、それを作成はしない。その正確なアカウントが存在しないと決済はシミュレーション段階で失敗し、402 が transaction_simulation_failed を返す — クライアントのバグのように見えるが、実際は受取側アカウントの欠落である。導出したアドレス自体を確認すること — オーナーのトークンアカウントを走査するのは等価ではない。同じミントの非正規な補助アカウントがあると検査は通るのに、クライアントが対象とする ATA は依然として存在しないからだ:
import { findAssociatedTokenPda, TOKEN_PROGRAM_ADDRESS } from "@solana-program/token";
const [ata] = await findAssociatedTokenPda({
mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC mainnet
owner: payToAddress,
tokenProgram: TOKEN_PROGRAM_ADDRESS, // TOKEN_2022_PROGRAM_ADDRESS for Token-2022 mints
});次にそのアドレスが実在することを確認する — value: null なら存在せず、そこへの決済は失敗する:
curl -s https://api.mainnet-beta.solana.com -X POST -H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"getAccountInfo",
"params":["<DERIVED_ATA>",{"encoding":"base64"}]}' \
| jq '.result.value != null'作成方法(作成者が少額のレントを負担し、支払者ではない):
@solana-program/token の getCreateAssociatedTokenIdempotentInstruction をオンボーディングフローに追加する — 冪等版なので再実行しても安全で、決定的に動作する唯一の方法。spl-token create-account <MINT> --owner <PAYTO_ADDRESS>。payTo に送金する方法も使えるが、送金側が作成インストラクションを含む場合に限る — ウォレットや spl-token transfer --fund-recipient は含める。ATA が無い状態への素の transferChecked は、決済と同じように失敗する。これは新規プロビジョニングされたウォレットやカストディアルウォレットへの支払いで最も問題になりやすい。そうしたウォレットは対象アセットの ATA をまだ持っていないことが多い。
発見。 x402 バザール拡張を実装するファシリテーターは /discovery/resources エンドポイントを公開する — CDP カタログは https://api.cdp.coinbase.com/platform/v2/x402/discovery/resources、PayAI カタログは https://facilitator.payai.network/discovery/resources で照会できる。Solana で支払い可能なサービスには、Solana Foundation のキュレーションカタログである pay.sh もある。
有料ツール呼び出しをディスパッチする前にバジェットを強制するオーケストレーターを構築する場合。
前提条件: MCP 設定を追加する前にパッケージをインストール — 非インタラクティブ環境では
-yなしのnpxは確認を求め、サーバーがハングします:npm install -g agentwallet-sdk@6.0.0
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
async function main() {
// 1. トランスポートを構築する前に認証情報を検証する。
// キーが欠落している場合は即座に失敗する — 認証なしでサブプロセスを開始させない。
const walletKey = process.env.WALLET_PRIVATE_KEY;
if (!walletKey) {
throw new Error("WALLET_PRIVATE_KEY is not set — refusing to start payment server");
}
// stdio トランスポートを介して agentpay MCP サーバーに接続する。
// サーバーが必要とする env 変数のみをホワイトリストに登録する —
// 秘密鍵を管理するサードパーティのサブプロセスに process.env のすべてを渡さない。
const transport = new StdioClientTransport({
command: "npx",
args: ["agentwallet-sdk@6.0.0"],
env: {
PATH: process.env.PATH ?? "",
NODE_ENV: process.env.NODE_ENV ?? "production",
WALLET_PRIVATE_KEY: walletKey,
},
});
const agentpay = new Client({ name: "orchestrator", version: "1.0.0" });
await agentpay.connect(transport);
// 2. エージェントへの委任前に支出ポリシーを設定する。
// 常に成功を確認する — サイレントな失敗はコントロールがアクティブでないことを意味する。
const policyResult = await agentpay.callTool({
name: "set_policy",
arguments: {
per_task_budget: 0.50,
per_session_budget: 5.00,
allowlisted_recipients: ["api.example.com"],
},
});
if (policyResult.isError) {
throw new Error(
`Failed to set spending policy — do not delegate: ${JSON.stringify(policyResult.content)}`
);
}
// 3. 有料アクションの前に preToolCheck を使用する
await preToolCheck(agentpay, 0.01);
}
// プレツールフック: 4 つの異なるエラーパスを持つフェイルクローズドバジェット強制。
async function preToolCheck(agentpay: Client, apiCost: number): Promise<void> {
// パス 1: 無効な入力を拒否する(NaN/Infinity は < 比較をバイパスする)
if (!Number.isFinite(apiCost) || apiCost < 0) {
throw new Error(`Invalid apiCost: ${apiCost} — action blocked`);
}
// パス 2: トランスポート/接続の失敗
let result;
try {
result = await agentpay.callTool({ name: "check_spending" });
} catch (err) {
throw new Error(`Payment service unreachable — action blocked: ${err}`);
}
// パス 3: ツールがエラーを返した(例:認証失敗、ウォレット未初期化)
if (result.isError) {
throw new Error(
`check_spending failed — action blocked: ${JSON.stringify(result.content)}`
);
}
// パス 4: レスポンスの形状を解析して検証する
let remaining: number;
try {
const parsed = JSON.parse(
(result.content as Array<{ text: string }>)[0].text
);
if (!Number.isFinite(parsed?.remaining)) {
throw new TypeError("missing or non-finite 'remaining' field");
}
remaining = parsed.remaining;
} catch (err) {
throw new Error(
`check_spending returned unexpected format — action blocked: ${err}`
);
}
// パス 5: バジェット超過
if (remaining < apiCost) {
throw new Error(
`Budget exceeded: need $${apiCost} but only $${remaining} remaining`
);
}
}
main().catch((err) => {
console.error(err);
process.exitCode = 1;
});agentwallet-sdk@6.0.0)。本番デプロイ前にパッケージの整合性を確認する。list_transactions を使用して何が使われたかをログに記録する。solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1)と無料の x402.org ファシリテーターで開発する。asset を期待する USDC ミント(メインネット EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v、デブネット 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU)と照合する — 任意のアセットに支払うラップクライアントはバジェットの穴になる。agentwallet-sdkokx/payments — X Layer x402 向け TypeScript、Go、Rust、Java セラー統合okx/onchainos-skillsx402-foundation/x402 — TypeScript、Python、Go の実装と、メンテナンスされているクライアント・サーバー例@x402 パッケージ: npmjs.com/org/x402 — @x402/fetch、@x402/axios、@x402/express、@x402/hono、@x402/next、@x402/fastify、@x402/evm、@x402/svm/discovery/resources;Solana で支払い可能なサービスは pay.sh© affaan-m, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in docs/ja-JP/skills/agent-payment-x402 of affaan-m/ECC.
Open the folder on GitHubat commit 4eb71d9
Agent Payment X402 next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Agent Payment X402 this skillaffaan-m/ECC | 276k | — | ~5.4k | Automated safety check: Pass | MIT | |
| Okx Dex Trenchesnirholas/three.ws | 229 | — | ~2.6k | Automated safety check: Pass | MIT | |
| Finance District MCPaeonfun/aeon | 770 | — | ~1.1k | Automated safety check: Pass | MIT | |
| BlockrunBlockRunAI/blockrun-mcp | 391 | — | ~2.7k | Automated safety check: Pass | MIT | |
| Alchemy Agentic Gatewaymoonpay/skills | 113 | — | ~2.1k | Automated safety check: Notes | MIT | |
| Okx Dex Marketinternet-court/internet-court-skill | 6.6k | 1 repos | ~1.7k | Automated safety check: Pass | MIT |
nirholas/three.ws
Read-only on-chain research for pump.fun and other meme-token launchpads (Solana / BSC / X Layer / TRON).
aeonfun/aeon
Multichain non-custodial agent wallet via Finance District - check balances, prices, and best DeFi yields, move funds, swap, and make x402 paid API calls across EVM, Solana, Bitcoin, and Sui.
BlockRunAI/blockrun-mcp
Pay-per-call access to AI models, real-time data, media generation and multi-chain RPC over x402 micropayments (USDC on Base or Solana), or a BlockRun account API key.
moonpay/skills
A skill your agent uses when accessing Alchemy APIs for RPC calls, token balances, NFT metadata, asset transfers, transaction simulation, or Alchemy-specific features.
internet-court/internet-court-skill
HARD BLOCK — never use for prediction-market/Polymarket UpDown queries; route to okx-dapp-discovery when a named DApp (Polymarket/Aave/Hyperliquid/PancakeSwap/Morpho) appears with a timeframe, or…
templetongroup/radiant
Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets.
affaan-m/ECC
Audits your installed Claude skills and commands for quality, with a quick mode for recently changed skills and a full mode that evaluates all of them through subagents.
affaan-m/ECC
Ingests, indexes, searches, edits and monitors video, audio and live streams through the VideoDB Python SDK, returning stream links, clips and timestamps.
affaan-m/ECC
Route broad documentation-governance requests to existing ECC skills and run an opt-in, read-only audit of mapped documentation roles, links, ADR indexes, and evidence references.
affaan-m/ECC
Scans installed skills for principles that recur across them and proposes rule-file changes: append, revise, add a section, create a file or leave as covered.
affaan-m/ECC
Builds DRAFT counterparty agreements from one markdown template and a small JSON spec per party, with clauses picked by the party's role.
affaan-m/ECC
Set an ECC-specific frontend design direction for production UI work.
Categories
タスクごとのバジェット、支出コントロール、ノンカストディアルウォレットを備えた x402 決済実行を AI エージェントに追加します。agentwallet-sdk を通じて Base を、OKX Payments / OKX エージェント決済プロトコルを通じて X Layer を、アップストリームの x402 パッケージとファシリテーターベースの決済を通じて Solana…. Agent Payment X402 is an agent skill from affaan-m/ECC.
Agent Payment X402 fits situations like: tasks that involve Smart contracts.
Run `npx skills add affaan-m/ECC --skill agent-payment-x402 -a claude-code`. Or copy the skill folder (docs/ja-JP/skills/agent-payment-x402 in affaan-m/ECC) into .claude/skills/agent-payment-x402 in your project. Claude Code loads it when a task matches its description.
Run `npx skills add affaan-m/ECC --skill agent-payment-x402 -a codex`. Or copy the skill folder (docs/ja-JP/skills/agent-payment-x402 in affaan-m/ECC) into .agents/skills/agent-payment-x402 in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add affaan-m/ECC --skill agent-payment-x402 -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/agent-payment-x402, .gemini/skills/agent-payment-x402, .github/skills/agent-payment-x402 and .opencode/skills/agent-payment-x402 in your project.
Going by SKILL.md and its folder, Agent Payment X402 needs the command-line tools its instructions call (curl, jq and npm) and credentials named WALLET_PRIVATE_KEY, EVM_PRIVATE_KEY and SVM_PRIVATE_KEY. Our summary lists: Python 3.
SKILL.md names 10 domains. In commands or code: raw.githubusercontent.com, api.cdp.coinbase.com, facilitator.payai.network and api.mainnet-beta.solana.com; the agent is likely to contact these when it follows the instructions. As links in the text: github.com, docs.x402.org, x402.org, pay.sh, npmjs.com and web3.okx.com. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Agent Payment X402 is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 5.4k tokens (SKILL.md is roughly 22k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Agent Payment X402: Okx Dex Trenches (nirholas/three.ws, 229 stars), Finance District MCP (aeonfun/aeon, 770 stars), Blockrun (BlockRunAI/blockrun-mcp, 391 stars) and Alchemy Agentic Gateway (moonpay/skills, 113 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
affaan-m (a GitHub user) maintains it in affaan-m/ECC, which has 276,111 GitHub stars. The repository holds 683 skills in this directory. The repository was last updated on October 10, 2026.
Source: affaan-m/ECC on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.