affaan-m/ECC · critical · EnvironmentError
TRADING_WALLET_PRIVATE_KEY not set
Error message
TRADING_WALLET_PRIVATE_KEY not set
What it means
At startup, the agent reads `TRADING_WALLET_PRIVATE_KEY` from the environment; if unset/empty, it raises `EnvironmentError("TRADING_WALLET_PRIVATE_KEY not set")` before constructing the `Account`. This is a fail-fast on missing secret so the agent never runs unauthenticated.
Source
Thrown at skills/llm-trading-agent-security/SKILL.md:120
if self.hour_start_value <= 0:
self.halt("Invalid hour_start_value")
return
hourly_pnl = (portfolio_value - self.hour_start_value) / self.hour_start_value
if hourly_pnl < -self.MAX_HOURLY_LOSS_PCT:
self.halt(f"Hourly PnL {hourly_pnl:.1%} below threshold")
```
### Wallet isolation
```python
import os
from eth_account import Account
private_key = os.environ.get("TRADING_WALLET_PRIVATE_KEY")
if not private_key:
raise EnvironmentError("TRADING_WALLET_PRIVATE_KEY not set")
account = Account.from_key(private_key)
```
Use a dedicated hot wallet with only the required session funds. Never point the agent at a primary treasury wallet.
### MEV and deadline protection
```python
import time
PRIVATE_RPC = "https://rpc.flashbots.net"
MAX_SLIPPAGE_BPS = {"stable": 10, "volatile": 50}
deadline = int(time.time()) + 60
```
## Pre-Deploy Checklist
View on GitHub (pinned to 01e15490f0)
Solutions
- Set the variable in the runtime environment (`.env` for local, secret manager / k8s secret for prod) and confirm with `printenv TRADING_WALLET_PRIVATE_KEY`.
- Load `.env` explicitly at startup (`load_dotenv()`) before the check.
- Make sure the var name casing matches exactly — environment variables are case-sensitive on POSIX.
- If using a masked CI value, confirm the real value is what reaches the process (not the `***` placeholder).
Example fix
# before
private_key = os.environ.get("TRADING_WALLET_PRIVATE_KEY")
if not private_key:
raise EnvironmentError("TRADING_WALLET_PRIVATE_KEY not set")
# after — fail fast with actionable message; load .env in dev
from dotenv import load_dotenv
load_dotenv()
private_key = os.environ.get("TRADING_WALLET_PRIVATE_KEY")
if not private_key or private_key.startswith("***"):
raise EnvironmentError("TRADING_WALLET_PRIVATE_KEY missing or masked; set it in the environment/secret manager") Defensive patterns
Strategy: validation
Validate before calling
import os
def has_wallet_key() -> bool:
v = os.environ.get('TRADING_WALLET_PRIVATE_KEY')
return bool(v) and not v.startswith('***') Type guard
null
Try / catch
try:
account = Account.from_key(os.environ['TRADING_WALLET_PRIVATE_KEY'])
except (KeyError, EnvironmentError) as e:
log.error('secret missing: %s', e)
sys.exit(2) # fail fast, do not run unauthenticated Prevention
- Load `.env` at startup (`load_dotenv()`) in dev.
- Inject secrets via the platform secret manager (k8s secret, AWS SM), not the image.
- Use a dedicated hot wallet with only session funds; never the treasury key.
When it happens
Trigger: Process started without `TRADING_WALLET_PRIVATE_KEY` in the environment — `.env` not loaded, secret manager unreachable, deployed without the var, or name typo.
Common situations: Forgot to `export` the var in the shell. `python-dotenv` not loaded in the entrypoint. Container missing the secret volume/env. Different casing (`Trading_Wallet_Private_Key`). CI masked the var and the run used the literal masked string.
Related errors
- The canonical ito-compute-cli is unpublished and ECC will no
- Project memory .gitignore does not contain the required fail
- Refusing to save memory containing a suspected secret (${sec
- Refusing to ${action} '${target}': no trusted install root r
- Potential prompt injection: {text[:100]}
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/343e52613dc0669f.
Report an issue: GitHub.