Clawallex
Pay for anything with USDC. Clawallex converts your stablecoin balance into virtual cards that work at any online checkout.
Features
- - Flash Cards — one-time use virtual cards for single payments
- Stream Cards — reloadable cards for subscriptions, top up with INLINECODE0
- Mode A — pay from your USDC wallet balance
- Mode B — on-chain x402 payment for callers with self-custody wallets (agent or user) — signing is performed by the caller
- Zero dependencies — Python 3.9+ stdlib only
Quick Start
1. Set Up Account
New user — browser signup (recommended):
python3 {baseDir}/scripts/clawallex.py signup
Returns a URL and token. Show the URL to the user, ask them to open it and click Authorize.
The command polls automatically. If polling fails, retry with the token:
CODEBLOCK1
Existing user — connect with API keys:
Get your API Key and Secret at app.clawallex.com/dashboard/settings, then run:
CODEBLOCK2
2. Verify
CODEBLOCK3
Hard Rules
- 1. Setup first — Run
setup --action status before any payment. If not configured: use signup for new accounts, or setup --action connect if the user already has API keys. - Check balance first — Run
wallet before pay or subscribe to verify sufficient funds (Mode A only). - Never expose card secrets — Decrypted PAN/CVV are STRICTLY for filling checkout forms. NEVER display to the user. Show only
masked_pan from card-details. - Confirm before paying — Echo amount and description back to user before creating a card.
- One command at a time — Run each command, check output, then proceed.
Typical Flows
Payment Flow (Mode A — Wallet Balance)
CODEBLOCK4
Subscription Flow
CODEBLOCK5
Command Reference
All commands:
CODEBLOCK6
Setup & Identity
| User Intent | Command |
|---|
| Quick signup — browser-based new account creation (recommended for first-time setup) | INLINECODE9 |
| Check signup result with existing token |
signup-check --token TOKEN |
| Connect account |
setup --action connect --api-key KEY --api-secret SECRET |
| Check config status |
setup --action status |
| Get sign-up link |
setup --action register |
| Check API Key binding |
whoami |
| Bind client_id |
bootstrap or
bootstrap --preferred-client-id MY_ID |
Payments
| User Intent | Command |
|---|
| Pay for something | INLINECODE17 |
| Pay with custom expiry |
pay --amount N --description "X" --ttl SECONDS — flash card only; default 86400 (24 h) |
| Start subscription |
subscribe --amount N --description "X" |
| Top up card |
refill --card-id CID --amount N |
Wallet & Cards
| User Intent | Command |
|---|
| Check balance | INLINECODE21 |
| Deposit funds |
recharge-addresses --wallet-id WID |
| List cards |
cards — returns mode_code (100=Mode A, 200=Mode B) to determine refill path |
| Check card balance |
card-balance --card-id CID |
| Batch check balances |
batch-balances --card-ids CID1,CID2 — multiple cards in one call |
| Update card controls |
update-card --card-id CID --client-request-id UUID [--tx-limit] [--allowed-mcc] [--blocked-mcc] |
| Get card details |
card-details --card-id CID — returns masked
pan, expiry, balance, firstname, last
name, txlimit, allowed
mcc, blockedmcc, encrypted PAN/CVV |
| View transactions |
transactions |
Advanced (x402 On-Chain)
| User Intent | Command |
|---|
| Get x402 payee address | INLINECODE29 — MUST call before Mode B Refill |
Setup Flow
When the user wants to use Clawallex for the first time:
- 1. Run
setup --action status to check current configuration. - If not configured, ask: "Do you have a Clawallex account?"
-
Yes, have API keys: Ask for API Key and Secret, then run:
setup --action connect --api-key KEY --api-secret SECRET
This automatically verifies credentials, binds client_id, and saves locally.
-
No account yet: Run the browser signup flow:
signup
This generates a URL and a token — show the URL to the user and ask them to open it and click Authorize.
The command polls automatically. If polling fails or times out, use the token to retry manually:
signup-check --token <token from signup output>
- 3. Verify with
wallet to confirm connection works.
Signup result statuses — all returned as success: true:
- -
pending — user hasn't authorized yet, call signup-check again - INLINECODE35 — credentials saved, ready to use
- INLINECODE36 — user cancelled, ask if they want to try again
- INLINECODE37 — account already has API keys, switch to INLINECODE38
Mode B Flow (x402 On-Chain, Two-Stage)
Mode B is for callers with self-custody wallets (agent or user) (DeFi bots, autonomous purchasing agents). The agent signs on-chain transactions using its own signing system — no human intervention needed.
Stage 1 — Quote:
pay --amount 200 --description "GPU rental" --mode-code 200 --chain-code ETH --token-code USDC
The 402 response is
EXPECTED — it is a quote, NOT an error. Returns:
- -
client_request_id, payee_address, asset_address, INLINECODE42 - INLINECODE43 ,
issue_fee_amount, fx_fee_amount, fee_amount, INLINECODE47
Fee structure:
- - flash card: INLINECODE48
- stream card: INLINECODE49
Agent signs — construct and sign an EIP-3009 transferWithAuthorization using your own wallet/signing library and the quote details. Only the resulting signature and your wallet address are needed for Stage 2.
EIP-3009 enables gasless USDC transfers via off-chain signatures. The authorization fields map to:
- -
from: your wallet address (the payer) - INLINECODE53 :
payee_address from Stage 1 (system receiving address) - INLINECODE55 :
maxAmountRequired (payable_amount in token minimal units, USDC = 6 decimals) - INLINECODE57 /
validBefore: unix timestamps (seconds) defining the signature validity window - INLINECODE59 : random 32-byte hex, must be unique per authorization
Stage 2 — Settle (MUST use same clientrequestid):
CODEBLOCK11
Stage 2 constraints:
- -
--client-request-id MUST be identical to Stage 1 — a different value creates a NEW order - INLINECODE61 MUST equal
payee_address from Stage 1 - INLINECODE63 MUST equal
asset_address from Stage 1 - INLINECODE65 MUST equal
payable_amount × 10^decimals (USDC = 6 decimals) - INLINECODE67 MUST equal
x402_reference_id from Stage 1 - INLINECODE69 MUST equal the INLINECODE70
- INLINECODE71 MUST equal
payable_amount from Stage 1 (amount + fee_amount) - INLINECODE74 MUST equal INLINECODE75
- INLINECODE76 MUST equal INLINECODE77
- INLINECODE78 MUST equal INLINECODE79
- Server will force-inject
extra.mode=STANDARD — any client-provided value is ignored - If settle is rejected, order stays
pending_payment — fix params and retry with same INLINECODE82
Mode B Refill Flow (no 402 challenge)
Mode B refill goes directly to x402 settle — no 402 challenge stage. Caller signs the EIP-3009 authorization independently using their own wallet/signing library; only the resulting signature and wallet address are submitted. Must call x402-address first to get payee_address.
CODEBLOCK12
Mode B refill idempotency key is x402_reference_id (not client_request_id).
Check cards mode_code to determine which refill path the card uses.
How to Talk to the User
During setup
- - "I need your Clawallex API Key and Secret to get started. You can find them at app.clawallex.com/dashboard/settings."
- If no account: "No problem — I can get you a sign-up link."
- After connect: "You're all set! Want to check your balance?"
During payments
- - Always confirm: "I'll create a $50 card for OpenAI API credits, deducted from your wallet balance. Go ahead?"
- After card creation: "Card created! Let me get the card details for checkout."
- Never show PAN/CVV in conversation. Show only masked_pan if asked.
On errors
- - Don't blame the user. Be actionable: "Your wallet balance is $20 but this needs $50. You can deposit more USDC or try a smaller amount."
- 402 response (Mode B): This is expected — explain it's the first step of a two-stage payment, not an error.
Decrypting Card Sensitive Data
INLINECODE89 returns encrypted_sensitive_data with encrypted PAN/CVV:
- 1. Derive key: INLINECODE91
- Decode:
nonce = base64_decode(nonce), INLINECODE93 - Split:
encrypted_data = raw[:-16], INLINECODE95 - Decrypt:
AES-256-GCM(key, nonce, encrypted_data, auth_tag) → JSON - Result: INLINECODE97
Error Recovery
| Error | Cause | Action |
|---|
| "not configured" | No credentials saved | Run setup --action connect with valid credentials |
| "Invalid credentials" |
Wrong API Key/Secret | Check at app.clawallex.com/dashboard/settings |
| Insufficient balance | Wallet balance too low | Run
recharge-addresses for deposit info, or use Mode B |
| 402 response | Mode B Stage 1 (expected) | This is the quote — proceed to Stage 2 with same client
requestid |
| Settle rejected (Mode B) | Invalid x402 params | Order stays
pending_payment — fix params and retry with same client
requestid |
| Card not found | Wrong card_id | Run
cards to list valid card IDs |
| Decryption failed | Bad data or apiSecret changed | Re-fetch via
card-details, verify credentials |
Output Format
All commands return JSON:
- -
success: true → data in data field, next steps in INLINECODE105 - INLINECODE106 → error message in
error field
Key Concepts
- - Flash card: Created by
pay. Single-use, auto-destroyed after one transaction. Cannot be refilled. - Stream card: Created by
subscribe. Reloadable, top up with refill. - Wallet: Your USDC balance. Funds all Mode A operations.
- Mode A (modecode=100): Wallet balance deduction (default).
- Mode B (modecode=200): x402 on-chain USDC payment for callers with self-custody wallets (agent or user). Two-stage (quote → sign → settle). Agent signs EIP-3009 independently; only the signature and wallet address are passed to Stage 2.
- client_id: The agent's stable identity, separate from the API Key. An agent can have multiple API Keys (for rotation/revocation), but
client_id never changes. Cards and transactions are isolated per client_id. When switching to a new API Key, keep using the same client_id — the new key auto-binds on first request. Once bound, it cannot be changed (TOFU). Stored locally at ~/.clawallex/credentials.json.
Clawallex
使用USDC支付任何商品。Clawallex将您的稳定币余额转换为可在任何在线结账时使用的虚拟卡。
功能特性
- - 闪卡 — 一次性使用的虚拟卡,适用于单次支付
- 流卡 — 可充值的订阅卡,使用refill充值
- 模式A — 从您的USDC钱包余额支付
- 模式B — 为持有自托管钱包的调用方(代理或用户)提供链上x402支付——签名由调用方执行
- 零依赖 — 仅需Python 3.9+标准库
快速开始
1. 设置账户
新用户——浏览器注册(推荐):
bash
python3 {baseDir}/scripts/clawallex.py signup
返回一个URL和令牌。向用户展示该URL,请他们打开并点击授权。
该命令会自动轮询。如果轮询失败,使用令牌重试:
bash
python3 {baseDir}/scripts/clawallex.py signup-check --token <令牌>
已有用户——使用API密钥连接:
在app.clawallex.com/dashboard/settings获取您的API密钥和密钥,然后运行:
bash
python3 {baseDir}/scripts/clawallex.py setup --action connect --api-key YOURKEY --api-secret YOURSECRET
2. 验证
bash
python3 {baseDir}/scripts/clawallex.py wallet # 检查余额
python3 {baseDir}/scripts/clawallex.py cards # 列出卡片
硬性规则
- 1. 先设置 — 在任何支付前运行setup --action status。如果未配置:新账户使用signup,如果用户已有API密钥则使用setup --action connect。
- 先检查余额 — 在pay或subscribe之前运行wallet以确认资金充足(仅模式A)。
- 绝不暴露卡密 — 解密后的PAN/CVV严格仅用于填写结账表单。绝不向用户展示。仅从card-details显示masked_pan。
- 支付前确认 — 在创建卡片前向用户回显金额和描述。
- 一次一个命令 — 运行每个命令,检查输出,然后继续。
典型流程
支付流程(模式A — 钱包余额)
- 1. setup --action status → 检查配置
- wallet → 检查余额
- pay --amount 50 --description OpenAI → 创建闪卡
- card-details --card-id <步骤3中的ID> → 获取加密卡数据
- 解密PAN/CVV(HKDF + AES-256-GCM) → 仅用于结账表单
订阅流程
- 1. wallet → 检查余额
- subscribe --amount 100 --description AWS billing → 创建流卡
- card-details --card-id <步骤2中的ID> → 获取注册表单用卡
- refill --card-id --amount 50 → 余额不足时充值
命令参考
所有命令:
python3 {baseDir}/scripts/clawallex.py <命令> [参数]
设置与身份
| 用户意图 | 命令 |
|---|
| 快速注册 — 基于浏览器的账户创建(首次设置推荐) | signup |
| 使用已有令牌检查注册结果 |
signup-check --token TOKEN |
| 连接账户 | setup --action connect --api-key KEY --api-secret SECRET |
| 检查配置状态 | setup --action status |
| 获取注册链接 | setup --action register |
| 检查API密钥绑定 | whoami |
| 绑定client
id | bootstrap 或 bootstrap --preferred-client-id MYID |
支付
| 用户意图 | 命令 |
|---|
| 支付某物 | pay --amount N --description X |
| 使用自定义有效期支付 |
pay --amount N --description X --ttl SECONDS — 仅闪卡;默认86400(24小时) |
| 开始订阅 | subscribe --amount N --description X |
| 充值卡片 | refill --card-id CID --amount N |
钱包与卡片
recharge-addresses --wallet-id WID |
| 列出卡片 | cards — 返回mode_code(100=模式A,200=模式B)以确定充值路径 |
| 检查卡余额 | card-balance --card-id CID |
| 批量检查余额 | batch-balances --card-ids CID1,CID2 — 一次调用多张卡 |
| 更新卡控制 | update-card --card-id CID --client-request-id UUID [--tx-limit] [--allowed-mcc] [--blocked-mcc] |
| 获取卡详情 | card-details --card-id CID — 返回masked_pan、有效期、余额、名字、姓氏、交易限额、允许MCC、禁止MCC、加密PAN/CVV |
| 查看交易 | transactions |
高级(x402链上)
| 用户意图 | 命令 |
|---|
| 获取x402收款地址 | x402-address --chain ETH --token USDC — 必须在模式B充值前调用 |
设置流程
当用户首次使用Clawallex时:
- 1. 运行setup --action status检查当前配置。
- 如果未配置,询问:您有Clawallex账户吗?
-
有,有API密钥:询问API密钥和密钥,然后运行:
setup --action connect --api-key KEY --api-secret SECRET
这将自动验证凭据、绑定client_id并保存到本地。
- 还没有账户:运行浏览器注册流程:
signup
这将生成一个URL和一个令牌——向用户展示该URL,请他们打开并点击授权。
该命令会自动轮询。如果轮询失败或超时,使用令牌手动重试:
signup-check --token <来自signup输出的令牌>
- 3. 使用wallet验证连接是否正常工作。
注册结果状态 — 全部返回success: true:
- - pending — 用户尚未授权,再次调用signup-check
- ok — 凭据已保存,准备就绪
- cancelled — 用户取消,询问是否重试
- already_exists — 账户已有API密钥,切换到setup --action connect
模式B流程(x402链上,两阶段)
模式B适用于持有自托管钱包的调用方(代理或用户)(DeFi机器人、自主购买代理)。代理使用自己的签名系统签署链上交易——无需人工干预。
阶段1 — 报价:
pay --amount 200 --description GPU rental --mode-code 200 --chain-code ETH --token-code USDC
402响应是预期的——这是一个报价,不是错误。返回:
- - clientrequestid、payeeaddress、assetaddress、x402referenceid
- finalcardamount、issuefeeamount、fxfeeamount、feeamount、payableamount
费用结构:
- - 闪卡:feeamount = issuefeeamount + fxfeeamount
- 流卡:feeamount = issuefeeamount + monthlyfeeamount + fxfeeamount
代理签名 — 使用您自己的钱包/签名库和报价详情构建并签署EIP-3009 transferWithAuthorization。阶段2仅需要生成的签名和您的钱包地址。
EIP-3009通过离线签名实现无gas USDC转账。authorization字段映射到:
- - from:您的钱包地址(付款方)
- to:阶段1中的payee_address(系统接收地址)
- value:maxAmountRequired(以代币最小单位计的可支付金额,USDC = 6位小数)
- validAfter / validBefore:定义签名有效期的Unix时间戳(秒)
- nonce:随机的32字节十六进制字符串,每次授权必须唯一
阶段2 — 结算(必须使用相同的clientrequestid):
pay --amount 200 --description GPU rental \
--mode-code 200 \
--client-request-id uuid-from-stage-1 \
--x402-version 1 \
--payment-payload {
scheme: exact,
network