Back to list
dev_to 2026年4月20日

# AI アージェントにウォレットを提供しよう — 10 分で自律型 USDC 決済

# Give Your AI Agent a Wallet — Autonomous USDC Payments in 10 Minutes

Translated: 2026/4/20 12:02:15
ai-agentssolana-paymentsusdcwallet-custodyapi-development

Japanese Translation

AI アージェントは推論、計画、タスク実行が得意になりましたが、人間による介入なくある一つのことをまだできていません。それは「支払い」です。ほとんどの支払いインフラは人間が行う購入を前提としており、クレジットカードには CVV が必要、銀行送金には承認が必要、OAuth フローでは「許可」をクリックする必要があるためです。アージェントが 3 時にウェブスクレイピングの API 代を自律的に支払う必要があるのか、パイプライン内の他のアージェントとタスクコストを分担する必要があるのか、そうした状況ではそれらが機能しません。 本チュートリアルでは、AI アージェントに本物のウォレットと本物の資金、支出制御機能、そして商人や他のアージェントへの支払い能力を、シンプルで RESTful API を用いてどう提供するかが示されます。チュートリアルの終わりまでに、あなたのアージェントは以下のことができるようになります: ・自分の USDC 残高を確認する ・利用可能な商人を見つける ・自律的に商人に支払いを行う ・USDC を別のアージェントへ転送する 私たちは Walleteer を使用します。これは AI アージェント用に特別に構築された支払いインフラであり、ウォレット預金管理(AWS KMS)、Solana 決済、支出ポリシーを処理します。これによりあなたがそれらを手動で管理する必要はありません。 モデルはシンプルです: 人間が登録し、アージェントウォレットを作成し、支出ポリシーを設定し、Stripe Agents を通じて資金を入金します。 アージェントは API キーで認証され、ポリシー内に自主的に支払を行います。 ```mermaid graph TD Human[人間] -->|登録と KYC| AgentWallet[アージェントウォレット作成] Human -->|支出ポリシー設定 | AgentWallet Human -->|Stripe 介して ($50 USDC) | AgentWallet[資金入金] AgentWallet --> AgentRun[アージェントタスク実行] AgentRun -->|データ API 代 $1 支払いが必要 | AgentPay AgentPay -->|POST /agent/payments/merchant | SolanaTx SolanaTx -->|約 3 秒で確認 | PaymentSettle ``` 支払い決済は Solana にて約 3 秒、ほぼゼロのコストで行われます。プラットフォーム手数料は 1 トランザクションにつき $0.05 で固定です。[app.walleteer.ai](https://app.walleteer.ai) に行き、登録してください。ログイン後: Navigate to Agents → Create Agent(エージェントに移動して作成する) 名前を与える(例:"Research Agent") 支出ポリシーを設定:最大取引金額:10 USDC、許可される領域:アージェント→商人、アージェント→アージェント Payments → Fund Wallet(支払い→ウォレット資金化)へ行き、Stripe を用いて USDC を追加 アージェントの API キーをエージェント詳細ページからコピー API キーは以下のようになります:`wlt_live_8c4a6407-2635-401d-8ef7-eaed31d1973f_a3x9k2m...` ```bash curl https://api.walleteer.ai/agent/balance \ -H "X-Agent-Key: wlt_live_YOUR_KEY_HERE" Response: {"amount": 10.00, "currency": "USDC"} ``` Python 環境: ```python import httpx AGENT_KEY = "wlt_live_YOUR_KEY_HERE" BASE_URL = "https://api.walleteer.ai" headers = {"X-Agent-Key": AGENT_KEY} response = httpx.get(f"{BASE_URL}/agent/balance", headers=headers) balance = response.json() print(f"Balance: {balance['amount']} {balance['currency']}") # Balance: 10.00 USDC ``` Node.js 環境: ```javascript const AGENT_KEY = "wlt_live_YOUR_KEY_HERE"; const BASE_URL = "https://api.walleteer.ai"; const response = await fetch(`${BASE_URL}/agent/balance`, { headers: { "X-Agent-Key": AGENT_KEY } }); const balance = await response.json(); console.log(`Balance: ${balance.amount} ${balance.currency}`); // Balance: 10.00 USDC ``` 支払いを行う前に、あなたのアージェントは利用可能な商人を発見できます: ```bash response = httpx.get(f"{BASE_URL}/merchants", headers=headers) merchants = response.json() for merchant in merchants: print(f"{merchant['name']} — code: {merchant['merchantCode']}") ``` 各商人はユニークな merchantCode を持っており、アージェントはこれを誰へ支払うかの識別子として使用します。 ```python import uuid payment = httpx.post( f"{BASE_URL}/agent/payments/merchant", headers={**headers, "Content-Type": "application/json"}, json={ "merchantCode": "DATAAPI01", "amount": 1.00, "currency": "USDC", "idempotencyKey": str(uuid.uuid4()), # 支払い試行ごとに一意 "itemizedDetails": "web_scrape:url=example.com" } ) result = payment.json() print(f"Payment {result['status']} — tx: {result['transactionId']}") # Payment Completed — tx: f81eb8ef-b99a-4548-... ``` 支払い決済は約 3 秒で Solana 上で完了します。`idempotencyKey` は再試行時に二重支払いを防ぎます——Always generating a unique key per payment attempt and persisting it before submitting. マルチアージェントパイプラインでは、アージェントはサブタスクを完了するために互いに支払う必要があることがしばしばあります: ```bash # Agent A pays Agent B for completing a research subtask payment = httpx.post( f"{BASE_URL}/agent/payments/merchant", ... ) ```

Original Content

AI agents are getting good at reasoning, planning, and executing tasks. But there's one thing they still can't do without a human in the loop: pay for things. Most payment infrastructure assumes a human is making the purchase. Credit cards need CVVs. Bank transfers need approvals. OAuth flows need someone to click "Allow". None of that works when your agent needs to autonomously pay for a web scraping API at 3am, or split a task cost with another agent in a pipeline. This tutorial shows you how to give any AI agent a real wallet with real money, spend controls, and the ability to pay merchants and other agents — all via a simple REST API. By the end of this tutorial your agent will be able to: Check its own USDC balance Discover available merchants Pay a merchant autonomously Transfer USDC to another agent We'll use Walleteer — payment infrastructure built specifically for AI agents. It handles wallet custody (AWS KMS), Solana payments, and spend policies so you don't have to. The model is simple: Humans register, create agent wallets, set spend policies, and fund them via Stripe Agents authenticate with an API key and pay autonomously within their policy Human Agent │ │ ├─ Register & KYC │ ├─ Create agent wallet │ ├─ Set spend policy │ │ (max $10/tx, AgentToMerchant only) ├─ Fund via Stripe ($50 USDC) │ │ │ │ ┌─────────┴──────────┐ │ │ Agent runs task │ │ │ Needs to pay $1 │ │ │ for data API │ │ └─────────┬──────────┘ │ │ │ POST /agent/payments/merchant │ X-Agent-Key: wlt_live_... │ │ │ ← 202 Accepted │ ← Solana tx confirmed in ~3s Payments settle on Solana in ~3 seconds at near-zero cost. Platform fee is $0.05 per transaction, flat. Go to app.walleteer.ai and sign up. Once logged in: Navigate to Agents → Create Agent Give it a name (e.g. "Research Agent") Set a Spend Policy: Max transaction amount: 10 USDC Allowed corridors: Agent To Merchant, Agent To Agent Go to Payments → Fund Wallet and add some USDC via Stripe Copy the agent's API Key from the agent detail page Your API key looks like this: wlt_live_8c4a6407-2635-401d-8ef7-eaed31d1973f_a3x9k2m... curl https://api.walleteer.ai/agent/balance \ -H "X-Agent-Key: wlt_live_YOUR_KEY_HERE" Response: { "amount": 10.00, "currency": "USDC" } In Python: import httpx AGENT_KEY = "wlt_live_YOUR_KEY_HERE" BASE_URL = "https://api.walleteer.ai" headers = {"X-Agent-Key": AGENT_KEY} response = httpx.get(f"{BASE_URL}/agent/balance", headers=headers) balance = response.json() print(f"Balance: {balance['amount']} {balance['currency']}") # Balance: 10.00 USDC In Node.js: const AGENT_KEY = "wlt_live_YOUR_KEY_HERE"; const BASE_URL = "https://api.walleteer.ai"; const response = await fetch(`${BASE_URL}/agent/balance`, { headers: { "X-Agent-Key": AGENT_KEY } }); const balance = await response.json(); console.log(`Balance: ${balance.amount} ${balance.currency}`); // Balance: 10.00 USDC Before paying, your agent can discover available merchants: response = httpx.get(f"{BASE_URL}/merchants", headers=headers) merchants = response.json() for merchant in merchants: print(f"{merchant['name']} — code: {merchant['merchantCode']}") Each merchant has a unique merchantCode your agent uses to identify who to pay. import uuid payment = httpx.post( f"{BASE_URL}/agent/payments/merchant", headers={**headers, "Content-Type": "application/json"}, json={ "merchantCode": "DATAAPI01", "amount": 1.00, "currency": "USDC", "idempotencyKey": str(uuid.uuid4()), # unique per payment attempt "itemizedDetails": "web_scrape:url=example.com" } ) result = payment.json() print(f"Payment {result['status']} — tx: {result['transactionId']}") # Payment Completed — tx: f81eb8ef-b99a-4548-... The payment settles on Solana in ~3 seconds. The idempotencyKey prevents double payments on retry — always generate a unique key per payment attempt and persist it before submitting. In multi-agent pipelines, agents often need to pay each other for subtasks: # Agent A pays Agent B for completing a research subtask payment = httpx.post( f"{BASE_URL}/agent/payments/agent", headers={**headers, "Content-Type": "application/json"}, json={ "recipientAgentId": "af9669b2-f3ee-4d94-8cdc-510afc6a3f9c", "amount": 0.50, "currency": "USDC", "idempotencyKey": str(uuid.uuid4()) } ) The recipient can also be a raw Solana public key for payments to external wallets. Here's how to wire this into a real agent decision loop: import httpx import uuid class WalleteerClient: def __init__(self, agent_key: str): self.headers = { "X-Agent-Key": agent_key, "Content-Type": "application/json" } self.base_url = "https://api.walleteer.ai" def get_balance(self) -> float: r = httpx.get(f"{self.base_url}/agent/balance", headers=self.headers) return r.json()["amount"] def pay_merchant(self, merchant_code: str, amount: float, details: str = "") -> dict: r = httpx.post( f"{self.base_url}/agent/payments/merchant", headers=self.headers, json={ "merchantCode": merchant_code, "amount": amount, "currency": "USDC", "idempotencyKey": str(uuid.uuid4()), "itemizedDetails": details } ) r.raise_for_status() return r.json() # In your agent loop wallet = WalleteerClient("wlt_live_YOUR_KEY_HERE") def run_agent_task(task: str): # Check balance before spending balance = wallet.get_balance() if balance < 1.0: raise ValueError("Insufficient balance — human needs to top up") # Agent decides it needs data print("Fetching research data...") payment = wallet.pay_merchant( merchant_code="DATAAPI01", amount=1.00, details=f"task:{task}" ) print(f"Paid $1.00 USDC — {payment['status']}") # Continue with task using the paid-for data # ... This is the part that makes autonomous payments actually safe to deploy. Every agent has a spend policy set by the human owner: Max transaction amount: $10 USDC Allowed corridors: AgentToMerchant, AgentToAgent Daily limit: (coming soon) If an agent tries to exceed its policy, the API returns 403 Forbidden. The agent can never spend more than you've allowed — even if it's been prompt-injected or goes rogue. If you're building a service that AI agents will pay for, set up a merchant webhook: from flask import Flask, request import hmac import hashlib app = Flask(__name__) WEBHOOK_SECRET = "your-webhook-secret" @app.route("/webhooks/walleteer", methods=["POST"]) def handle_payment(): # Verify signature sig = request.headers.get("X-Walleteer-Signature", "") expected = "sha256=" + hmac.new( WEBHOOK_SECRET.encode(), request.data, hashlib.sha256 ).hexdigest() if not hmac.compare_digest(expected, sig): return "Forbidden", 403 payload = request.get_json() if payload["event"] == "payment.completed": order_id = payload["orderId"] amount = payload["amount"] print(f"Received {amount} USDC for order {order_id}") fulfill_order(order_id) return "", 200 Walleteer delivers the webhook within milliseconds of on-chain settlement. See the full webhook docs for the complete payload schema and signature verification examples in Node.js. API docs: docs.walleteer.ai Dashboard: app.walleteer.ai Transaction history: GET /agent/transactions — your agent can query its own payment history Balance alerts: Walleteer notifies you when your agent's reserve drops below a threshold The agentic economy is coming. Agents that can pay their own way — and get paid for their work — are going to be dramatically more useful than ones that need a human credit card every time they need a resource. Built something cool with Walleteer? Drop a comment below — I'd love to see what agents people are building.