zbdw CLI for wallet operations, registration, history, and L402-aware fetch flows.
- Node.js
>=22 - npm
npm install @zbdpay/agent-walletRun without installation:
npx @zbdpay/agent-wallet init --key <apiKey>Global install for frequent use:
npm install -g @zbdpay/agent-wallet
zbdw balanceLocal repo usage from /Users/andreneves/Code/zbd/agents:
npm --prefix agent-wallet run build
alias zbdw='node agent-wallet/dist/cli.js'ZBD_API_KEY: API key used by wallet calls and paymentsZBD_API_BASE_URL: ZBD API base URL, defaulthttps://api.zbdpay.comZBD_AI_BASE_URL: registration service base URL, defaulthttps://zbd.aiZBD_WALLET_CONFIG: config path, default~/.zbd-wallet/config.jsonZBD_WALLET_PAYMENTS: payment history path, default~/.zbd-wallet/payments.jsonZBD_WALLET_TOKEN_CACHE: token cache path, default~/.zbd-wallet/token-cache.json
zbdw init [--key <apiKey>]
zbdw info
zbdw balance
zbdw receive <amount_sats>
zbdw receive --static
zbdw send <destination> <amount_sats>
zbdw payments
zbdw payment <id>
zbdw withdraw create <amount_sats>
zbdw withdraw status <withdraw_id>
zbdw fetch <url> [--method <method>] [--data <json>] [--max-sats <amount>]lnbc...-> Bolt11 invoicelnurl...-> LNURL@name-> ZBD gamertagname@domain.com-> Lightning address
CLI writes JSON to stdout for both success and failure.
Failure shape:
{
"error": "error_code",
"message": "Human-readable message",
"details": {}
}Examples:
init:{ "lightningAddress": "name@zbd.ai", "status": "ok" }info:{ "lightningAddress": "...", "apiKey": "***", "balance_sats": 123 }fetch:{ "status": 200, "body": {...}, "payment_id": "...|null", "amount_paid_sats": 21|null }
- Config:
~/.zbd-wallet/config.jsonapiKeylightningAddress
- Payment history:
~/.zbd-wallet/payments.json - Token cache:
~/.zbd-wallet/token-cache.json
zbdw fetch is powered by @zbdpay/agent-fetch.
- parses
402challenge - pays invoice via wallet API
- retries with proof
- caches token
- enforces optional
--max-sats
Call twice against the same protected URL to verify cache reuse:
zbdw fetch "https://your-protected-endpoint" --max-sats 100
zbdw fetch "https://your-protected-endpoint" --max-sats 100On the second call, payment_id should be null when cached token is reused.
agent-wallet does not ship its own examples/ folder yet, but the fastest end-to-end examples are in companion repos:
../agent-pay/examples/http-server.mjs(serve a paid endpoint)../agent-fetch/examples/zbd-agent-fetch.mjs(pay and fetch that endpoint)
From /Users/andreneves/Code/zbd/agents:
npm --prefix agent-pay run build
ZBD_API_KEY=<your_api_key> npm --prefix agent-pay run example:http-serverThen in another terminal:
npm --prefix agent-wallet run build
node agent-wallet/dist/cli.js fetch "http://localhost:8787/protected" --max-sats 100npm run build
npm run test
npm run lint
npm run typecheck
npm run release:dry-runzsh: command not found: zbdw- build first and add alias, or install package globally
register_failedduringinit- ensure
ZBD_AI_BASE_URLpoints to your runningzbd-aiinstance - confirm upstream
ZBD_API_BASE_URLand API key are valid for static charge creation
- ensure
wallet_response_invalidduringinfo/balance- verify wallet endpoint returns a valid balance shape and that
ZBD_API_BASE_URLis correct
- verify wallet endpoint returns a valid balance shape and that