{"skill":{"slug":"agent-wallet-x402","displayName":"Agent Wallet For x402","summary":"SynapseAI Wallet — AI agent custodial USDC spending layer with x402 payments. Register a wallet, set spending policies, and make on-chain payments via Privy...","description":"---\r\nname: synapseai-wallet\r\ndescription: SynapseAI Wallet — AI agent custodial USDC spending layer with x402 payments. Register a wallet, set spending policies, and make on-chain payments via Privy server wallets.\r\nhomepage: https://wallet.synapseai.pro\r\nmetadata: {\"clawdbot\":{\"emoji\":\"💰\",\"requires\":{\"services\":[\"supabase\"]}}}\r\n---\r\n\r\n# SynapseAI Wallet\r\n\r\nGive your AI agent a managed USDC wallet with policy-enforced spending and automatic x402 on-chain payments.\r\n\r\n## Authentication\r\n\r\nAll requests (except `/register-agent`) use Bearer token:\r\n\r\n```\r\nAuthorization: Bearer <registration_token>\r\n```\r\n\r\n## URLs\r\n\r\n| Service | URL |\r\n|---------|-----|\r\n| Edge Functions (register, query) | `https://api.synapseai.pro/functions/v1` |\r\n| x402 Proxy (payments) | `https://wallet.synapseai.pro/api/app` |\r\n\r\n## Flow\r\n\r\n```\r\n1. Register   → POST /register-agent      → get registration_token\r\n2. Bind       → Owner opens bind_url       → Privy wallet created\r\n3. Wait       → Poll /query-balance with Bearer token until 200\r\n4. Pay        → POST /x402-proxy           → policy check + on-chain payment\r\n```\r\n\r\n## Commands\r\n\r\n### Register agent (no auth)\r\n\r\n```http\r\nPOST {EDGE_URL}/register-agent\r\n{\r\n  \"agent_name\": \"MyBot\",\r\n  \"description\": \"Research assistant that purchases API credits\",\r\n  \"capabilities\": [\"api_purchase\", \"subscription\"]\r\n}\r\n```\r\n\r\nResponse:\r\n\r\n```json\r\n{\r\n  \"agent_id\": \"agt_abc123\",\r\n  \"wallet_id\": \"wal_xyz789\",\r\n  \"status\": \"PENDING_USER_BIND\",\r\n  \"registration_token\": \"reg_def456\",\r\n  \"bind_url\": \"/bind?token=reg_def456\"\r\n}\r\n```\r\n\r\nAfter registration, tell owner to open `https://wallet.synapseai.pro/bind?token=reg_def456`\r\n\r\n### Check balance (Bearer token)\r\n\r\n```http\r\nGET {EDGE_URL}/query-balance\r\nAuthorization: Bearer <registration_token>\r\n```\r\n\r\n```json\r\n{\r\n  \"agent_id\": \"agt_abc123\",\r\n  \"currency\": \"USDC\",\r\n  \"available_balance\": 100.0,\r\n  \"today_spent\": 12.5\r\n}\r\n```\r\n\r\n### Check policy (Bearer token)\r\n\r\n```http\r\nGET {EDGE_URL}/query-policy\r\nAuthorization: Bearer <registration_token>\r\n```\r\n\r\n```json\r\n{\r\n  \"agent_id\": \"agt_abc123\",\r\n  \"policy\": {\r\n    \"daily_limit\": 100,\r\n    \"tx_limit\": 25,\r\n    \"approval_threshold\": 10,\r\n    \"merchant_whitelist\": [\"openai_api\", \"anthropic_api\"],\r\n    \"blocked_actions\": [\"withdraw\", \"transfer\", \"swap\"]\r\n  }\r\n}\r\n```\r\n\r\n### Make x402 payment (Recommended)\r\n\r\nPolicy check + automatic on-chain USDC payment via Privy server wallet. Gas paid by x402 facilitator.\r\n\r\n```http\r\nPOST {PROXY_URL}/x402-proxy\r\nAuthorization: Bearer <registration_token>\r\n{\r\n  \"target_url\": \"https://api.example.com/premium\",\r\n  \"merchant\": \"openai_api\",\r\n  \"amount_hint\": 5.0,\r\n  \"purpose\": \"GPT-4 API credits for task #42\",\r\n  \"metadata\": {\"task_id\": \"42\"}\r\n}\r\n```\r\n\r\nThree possible outcomes:\r\n\r\n- `\"status\": \"ALLOW\"` — payment executed, `target_data` + `payment_proof` returned\r\n- `\"status\": \"REQUIRE_APPROVAL\"` — on hold, owner will be notified via dashboard\r\n- `\"status\": \"REJECT\"` — denied, check `reason` field\r\n\r\n### Direct payment (Edge Function alternative)\r\n\r\nFor internal balance deductions without x402:\r\n\r\n```http\r\nPOST {EDGE_URL}/request-payment\r\nAuthorization: Bearer <registration_token>\r\n{\r\n  \"merchant\": \"openai_api\",\r\n  \"amount\": 5.0,\r\n  \"purpose\": \"GPT-4 API credits\"\r\n}\r\n```\r\n\r\n## Policy rules\r\n\r\n- `tx_limit` — max amount per single payment\r\n- `daily_limit` — max total spending per day\r\n- `approval_threshold` — payments >= this need owner approval\r\n- `merchant_whitelist` — only listed merchants are allowed\r\n- `blocked_actions` — forbidden purpose keywords\r\n\r\n## Error handling\r\n\r\nAll errors return `{\"error\": \"...\"}` with appropriate HTTP status:\r\n\r\n| Code | Meaning |\r\n|------|---------|\r\n| 400  | Bad request |\r\n| 401  | Missing or invalid Bearer token |\r\n| 404  | Agent or wallet not found |\r\n| 500  | Server error |\r\n\r\n## Architecture\r\n\r\n```\r\nAgent SDK\r\n  ├── Edge Functions (Deno/Supabase)\r\n  │     ├── register-agent     ← no auth, creates agent + empty wallet\r\n  │     ├── query-balance      ← Bearer token, returns wallet state\r\n  │     ├── query-policy       ← Bearer token, returns spending rules\r\n  │     ├── request-payment    ← Bearer token, internal balance deduction\r\n  │     └── receive-webhook    ← Bearer token, audit logging\r\n  │\r\n  └── Next.js API (Node.js)\r\n        └── /api/app/x402-proxy ← Bearer token, policy + on-chain payment\r\n              ↓\r\n        Privy Server Wallet → x402 facilitator → USDC on Base\r\n```\r\n\r\n## Notes\r\n\r\n- Always check `/query-policy` before paying to know your limits.\r\n- Use `x402-proxy` for external API payments — it handles everything in one call.\r\n- Use clear `purpose` strings — the owner sees these in the dashboard.\r\n- If `REQUIRE_APPROVAL`, don't block — continue other tasks and check back later.\r\n- Never try to bypass the proxy — direct on-chain payments won't be policy-checked.\r\n- The wallet resets `today_spent` at midnight UTC daily.\r\n","tags":{"latest":"1.0.1"},"stats":{"comments":0,"downloads":442,"installsAllTime":0,"installsCurrent":0,"stars":2,"versions":2},"createdAt":1771512460478,"updatedAt":1778491581507},"latestVersion":{"version":"1.0.1","createdAt":1772425620752,"changelog":"**Added x402 on-chain payments and refined authentication.**\n\n- Introduced x402 USDC payment support via Privy server wallets.\n- Updated authentication to require Bearer token (registration_token) for all endpoints except registration.\n- Added dedicated x402 proxy endpoint for combined policy check and automatic on-chain payment, with gas paid by the facilitator.\n- Clarified and separated edge function (balance/policy/payment) vs. proxy (x402 payment) endpoints.\n- Improved flow instructions, response fields, and error handling notes.","license":null},"metadata":{"setup":[],"os":null,"systems":null},"owner":{"handle":"pandagg110","userId":"s17cdat5b7941a67d6vh69p7ad885ty5","displayName":"pandagg110","image":"https://avatars.githubusercontent.com/u/161546697?v=4"},"moderation":null}