Agent Patterns
How the WaaP CLI works under the hood and patterns for building robust agents.
How It Works
- Login — email + password → JWT (no cookies, no browser)
- Keyshare — fetched from the keyshare-manager and AES-GCM decrypted with
userKey - Signing — 2-party ECDSA (WASM + policy-engine over HTTP)
2FA: Newly created accounts start with Authorization Method set to
Disabled. To manage 2FA:waap-cli 2fa status/enable/disable. To bypass 2FA programmatically, pass--permission-token.
Risk Levels
The policy engine assigns a risk level to every signing request. When the highest risk level meets or exceeds the wallet’s Min Risk for 2FA threshold (default: HighWarn), 2FA authorization is required before the signature is released.
| Level | What it means |
|---|---|
Ok | No known risk — transaction proceeds without friction |
LowWarn | Minor risk detected — warning shown but no 2FA |
HighWarn | Significant risk — triggers 2FA if Min Risk for 2FA is set to HighWarn (default) |
HighWarnButGracefully | Routine high-risk (e.g., daily spend limit exceeded) — triggers 2FA |
Block | Extreme risk — transaction blocked by policy engine |
2FA Flow
When the policy engine determines that 2FA is required (i.e., highest_risk >= min_risk_for_2fa):
- Policy engine returns
WaitForAuthzduring signing. - CLI opens a WebSocket connection to
/listen-authz/{method}/{payloadId}/{jwt}. - For email: a verification link is sent — CLI waits for the user to click it.
- For phone: an OTP is sent via SMS — CLI prompts for the code via stdin.
- For wallet: a message is signed on the external hardware wallet.
- Timeout: 5 minutes — CLI exits with an error if no authorization is received.
Session Storage
- Session is saved at
~/.waap-cli/session.jsonwith0600permissions (owner read/write only). - Contains:
token,jwt,userKey, and optionallyuserId. waap-cli logoutdeletes this file.
RPC
For eth_getBalance, send-tx, and sign-tx, RPC can be passed with --rpc option flag.
If --rpc is omitted, the CLI auto-resolves a free public RPC:
- Fetches the chain list from
chainid.network/chains.json. - Caches the result for 24 hours at
~/.waap-cli/chains.json. - Prefers
publicnode.comRPCs, then falls back totatum.io.
Override with --rpc <url> for production reliability — free public RPCs may be rate-limited or unreliable.