{"_id":"@algo-wallet/x402-client","_rev":"2-15ea61e7e108d808451e857584efd09e","name":"@algo-wallet/x402-client","dist-tags":{"latest":"0.3.0"},"versions":{"0.2.0":{"name":"@algo-wallet/x402-client","version":"0.2.0","license":"MIT","_id":"@algo-wallet/x402-client@0.2.0","maintainers":[{"name":"m-reynaldo35","email":"gagoogalizer@gmail.com"}],"dist":{"shasum":"11a51a977f5f9d8fc56407bb1a6d302a05fb954e","tarball":"https://registry.npmjs.org/@algo-wallet/x402-client/-/x402-client-0.2.0.tgz","fileCount":18,"integrity":"sha512-y+wj6xKdICXGNa72Xng6Ryy9lRjoyo5dPqAoofB+IPPu1MfZab/0k5AoNc/cX3Cr47EE0De1mkhzGsenFdxjMQ==","signatures":[{"sig":"MEQCIF/rvAwUUovq3ECdLqNsH+pkICaGOsV9JyJWz00RCkK5AiB4jxlKe5YrENUt7o0DB+LXKO6FpS0NZRkcRT44tgMHPw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":50144},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"27f3f908606a65876f0fb362dad456ac05adf4ca","scripts":{"build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"m-reynaldo35","email":"gagoogalizer@gmail.com"},"_npmVersion":"11.8.0","description":"TypeScript SDK for x402-compliant AI-to-AI settlement on Algorand","directories":{},"_nodeVersion":"25.6.0","dependencies":{"algosdk":"^3.2.0"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.3"},"_npmOperationalInternal":{"tmp":"tmp/x402-client_0.2.0_1774216554989_0.9508464226723254","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@algo-wallet/x402-client","version":"0.3.0","description":"TypeScript SDK for x402-compliant AI-to-AI settlement on Algorand","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"}},"scripts":{"build":"tsc","prepublishOnly":"npm run build"},"dependencies":{"algosdk":"^3.2.0"},"devDependencies":{"typescript":"^5.7.3"},"engines":{"node":">=20"},"license":"MIT","gitHead":"7eb25bd959a0c2f7a957a4f01a2a9e06c0384f4f","_id":"@algo-wallet/x402-client@0.3.0","_nodeVersion":"25.6.0","_npmVersion":"11.8.0","dist":{"integrity":"sha512-jKbIrykeJuoiFYfcWyuCFRo1aj9LewhEy21Nk75/b36ZuTkfqq1zdmVa1IhErfWIX6DPCdGjDOPOrFK14dzxAg==","shasum":"469b634c09f511d50cef85dfce195bd6f7979433","tarball":"https://registry.npmjs.org/@algo-wallet/x402-client/-/x402-client-0.3.0.tgz","fileCount":18,"unpackedSize":52380,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCCI4VdzvLd0Pzj1ahT9LvKhsHAKFPKnfvnDPADhvkLJQIhAOCuqQS3YA7umwuOO6vKwAEO4hb2Sc5fv4jnunj18NBm"}]},"_npmUser":{"name":"m-reynaldo35","email":"gagoogalizer@gmail.com"},"directories":{},"maintainers":[{"name":"m-reynaldo35","email":"gagoogalizer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/x402-client_0.3.0_1774381102069_0.41667683318991355"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-22T21:55:54.810Z","modified":"2026-03-24T19:38:22.343Z","0.2.0":"2026-03-22T21:55:55.128Z","0.3.0":"2026-03-24T19:38:22.205Z"},"license":"MIT","description":"TypeScript SDK for x402-compliant AI-to-AI settlement on Algorand","maintainers":[{"name":"m-reynaldo35","email":"gagoogalizer@gmail.com"}],"readme":"# @algo-wallet/x402-client\n\nTypeScript SDK for x402-compliant AI-to-AI settlement on Algorand.\n\nHandles the full x402 payment handshake automatically — your agent never sees the `402`.\n\n## Install\n\n```bash\nnpm install @algo-wallet/x402-client algosdk\n```\n\n## Quick Start\n\n```typescript\nimport { AlgoAgentClient } from \"@algo-wallet/x402-client\";\n\nconst client = new AlgoAgentClient({\n  baseUrl: \"https://api.ai-agentic-wallet.com\",\n  privateKey: yourAlgorandSecretKey, // 64-byte Uint8Array\n});\n\nconst result = await client.executeTrade({ senderAddress: \"AAAA...7Q\" });\nconsole.log(result); // { success: true, settlement: { txnId: \"...\", confirmedRound: 12345 } }\n```\n\nThree lines. The SDK absorbs the 402 bounce, builds the Ed25519 proof, and settles the atomic group on-chain.\n\n## What Happens Under the Hood\n\n```\nexecuteTrade()\n  │\n  ├─ POST /api/agent-action           ← Initial request (no proof)\n  │    ↳ 402 Payment Required          ← Server bounces with pay+json terms\n  │\n  ├─ [interceptor] Parse 402 terms     ← Extract USDC amount, payTo, asset ID\n  ├─ [interceptor] Build atomic group  ← ASA transfer to treasury\n  ├─ [interceptor] Sign groupId        ← Ed25519 signature with your key\n  ├─ [interceptor] Retry with proof    ← X-PAYMENT header injected\n  │    ↳ 200 SandboxExport             ← Unsigned atomic group returned\n  │\n  └─ POST /api/execute                 ← Forward to settlement pipeline\n       ↳ 200 SettlementResult          ← On-chain confirmation (txnId, round)\n```\n\n## API\n\n### `new AlgoAgentClient(config)`\n\n| Parameter | Type | Required | Description |\n|-----------|------|----------|-------------|\n| `baseUrl` | `string` | Yes | x402 server URL |\n| `privateKey` | `Uint8Array` | Yes | 64-byte Algorand Ed25519 secret key |\n| `slippageBips` | `number` | No | Slippage tolerance (default: 50 = 0.5%) |\n\n### `client.executeTrade(params): Promise<TradeResult>`\n\nFull handshake → settlement in one call.\n\n| Parameter | Type | Required | Description |\n|-----------|------|----------|-------------|\n| `senderAddress` | `string` | Yes | Your Algorand address |\n| `amount` | `number` | No | Micro-USDC amount (default: 10000 = $0.01) |\n\n### `client.requestSandboxExport(params): Promise<AgentActionResponse>`\n\nPerforms the 402 handshake only. Returns the `SandboxExport` for inspection before settlement.\n\n### `client.settle(response): Promise<TradeResult>`\n\nForwards a previously obtained `AgentActionResponse` to `/api/execute`.\n\n## Types\n\nAll types are exported for full autocomplete:\n\n```typescript\nimport type {\n  TradeParams,\n  TradeResult,\n  SettlementResult,\n  SettlementFailure,\n  SandboxExport,\n  PayJson,\n} from \"@algo-wallet/x402-client\";\n```\n\n## Error Handling\n\n```typescript\nimport { X402Error } from \"@algo-wallet/x402-client\";\n\ntry {\n  const result = await client.executeTrade({ senderAddress: \"AAAA...7Q\" });\n  if (\"success\" in result) {\n    console.log(\"Settled:\", result.settlement.txnId);\n  } else {\n    console.error(\"Pipeline failed at:\", result.failedStage, result.detail);\n  }\n} catch (err) {\n  if (err instanceof X402Error) {\n    console.error(\"x402 protocol error:\", err.message);\n  }\n}\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}