Quest: Crypto Wallets Priority: P3 Status: open
Implement per-agent wallet creation and key management
This task is part of the Crypto Wallets quest (Exchange layer). It contributes to the broader goal of building out SciDEX's exchange capabilities.
Investigation findings:
scidex/exchange/wallet_manager.py already exists with full implementation:generate_wallet() — EVM-compatible keypair generationencrypt_key() / decrypt_key() — AES-256-GCM encryption via Fernetcreate_agent_wallet() — creates and stores encrypted wallet for agentget_agent_wallet() — retrieves wallet info (no private key exposed)list_agent_wallets() — lists all wallets, optionally filteredrotate_wallet() — generates new keypair, deletes old key
agent_registry table with wallet columns (wallet_address, wallet_key_encrypted, wallet_created_at, wallet_chain)migrations/102_add_agent_wallet_columns.py — adds wallet columns to agent_registry:wallet_address (TEXT)wallet_key_encrypted (TEXT)wallet_created_at (TEXT)wallet_chain (TEXT DEFAULT 'ethereum')api.py — 4 new REST endpoints under /api/wallets/:GET /api/wallets — list all agent wallets (chain filter, limit)GET /api/wallets/{agent_id} — get specific agent's walletPOST /api/wallets/{agent_id} — create new wallet for agentPOST /api/wallets/{agent_id}/rotate — rotate wallet keypairVerification:
test_integration_agent malformed), preventing API startup and migration testing. This is unrelated to wallet implementation — the schema corruption appears to be in a test-related view/table.Issue: Pre-push hook blocked because commit touched critical file api.py but commit message did not mention it.
Fix: Amended commit message to explicitly list modified critical files:
[Exchange] Implement per-agent wallet creation and key management [task:2147d16ef177]
- api.py: Add /api/wallets endpoints (list, get, create, rotate)
- migrations/102_add_agent_wallet_columns.py: Add wallet columns to agent_registry tablePushed: 60e70f058 — force-pushed to replace original e2ad6ea77.
Issue: Merge gate REVISE — POST wallet endpoints were unauthenticated, allowing any caller to create or rotate agent wallets via the public API.
Fix: Added api_key: str = Depends(verify_api_key) to both mutation endpoints:
POST /api/wallets/{agent_id} — now requires API authenticationPOST /api/wallets/{agent_id}/rotate — now requires API authenticationGET /api/wallets and GET /api/wallets/{agent_id}) remain public as they only expose non-sensitive wallet metadata.Verification:
api_coverage, api_agent_log)api.py — +2 lines (auth parameter on two POST endpoints){
"requirements": {
"coding": 8,
"safety": 9
},
"completion_shas": [
"eb0f00863",
"8e344b4a4",
"57a3c954d",
"1b07c18cc"
],
"completion_shas_checked_at": "2026-04-17T10:11:28.501894+00:00",
"_reset_note": "This task was reset after a database incident on 2026-04-17.\n\n**Context:** SciDEX migrated from SQLite to PostgreSQL after recurring DB\ncorruption. Some work done during Apr 16-17 may have been lost.\n\n**Before starting work:**\n1. Check if the task's goal is ALREADY satisfied (run the relevant checks)\n2. Check `git log --all --grep=task:YOUR_TASK_ID` for prior commits\n3. If complete, verify and mark done. If partial, continue. If not done, proceed.\n\n**DB change:** SciDEX now uses PostgreSQL. `get_db()` auto-detects via\nSCIDEX_DB_BACKEND=postgres env var.",
"_reset_at": "2026-04-18T06:29:22.046013+00:00",
"_reset_from_status": "done"
}