Overview
Every command that needs a private key follows the same lookup order. This avoids requiring--private-key on every command while still allowing explicit overrides.
Private Key Lookup Order
--private-key <path>flag (if provided) — Use this file directly.COWBOY_PRIVATE_KEYenvironment variable — If set, treat the value as a hex-encoded 32-byte private key..cowboy/config.json— Readkey_filefrom the active environment, resolved relative to.cowboy/..cowboy/key— Fallback for backward compatibility (walk up from the current directory to find the nearest.cowboy/keyfile, same pattern as.git/discovery).
Key File Formats
The CLI supports two key file formats and auto-detects which is in use: PEM format (current default):0x prefix is accepted but not required for hex format. Trailing newlines are trimmed. Use cowboy wallet upgrade to convert hex keys to PEM format.
Directory Walking
The CLI searches for.cowboy/ starting from the current working directory and walking up to the filesystem root:
RPC URL Discovery
The same pattern applies to the RPC URL:--rpc-url <url>flag (if provided).COWBOY_RPC_URLenvironment variable..cowboy/config.jsonfile (readrpc_urlfrom the active environment).- Default:
http://localhost:4000.
config.json format (multi-environment):
Commands Using Auto-Discovery
Every command that needs a private key or RPC URL uses auto-discovery. This is critical for the zero-config promise — aftercowboy init local, all commands
just work without extra flags.
| Command | Discovers key | Discovers RPC URL |
|---|---|---|
cowboy wallet address | Yes | — |
cowboy wallet balance | Yes | Yes |
cowboy wallet upgrade | Yes | — |
cowboy actor deploy | Yes | Yes |
cowboy actor execute | Yes | Yes |
cowboy actor get | — | Yes |
cowboy actor logs | — | Yes |
cowboy transfer | Yes | Yes |
cowboy account * | — | Yes |
cowboy transaction submit | — | Yes |
cowboy transaction get/status | — | Yes |
cowboy block * | — | Yes |
cowboy query * | — | Yes |
cowboy runner register | Yes | Yes |
cowboy runner get/list | — | Yes |
cowboy job submit | Yes | Yes |
cowboy job get/status/runners/results/verified | — | Yes |
cowboy token create/transfer/approve/mint/burn/freeze/unfreeze | Yes | Yes |
cowboy token info/balance/list | — | Yes |
cowboy watchtower init | Yes | Yes |
cowboy watchtower new feed | Yes | Yes |
cowboy watchtower feed <id> publish | Yes | Yes |
cowboy watchtower feeds | Yes | Yes |
cowboy watchtower list | — | Yes |
cowboy watchtower feed <id> subscribers | — | Yes |

