nansen-wallet-keychain-migration
Original:🇺🇸 English
Translated
Migrate an existing nansen-cli wallet from insecure password storage (env files, .credentials) to the new secure keychain-backed flow.
3installs
Sourcenansen-ai/nansen-cli
Added on
NPX Install
npx skill4agent add nansen-ai/nansen-cli nansen-wallet-keychain-migrationTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Wallet Migration — Old Flow to Secure Keychain
Use this skill when a user already has a nansen-cli wallet set up with the
old password storage method and wants to migrate to the new secure flow.
When to use
- User mentions they stored their password in , a
~/.nansen/.envfile, or.envmemory.md - User gets the stderr warning:
⚠ Password loaded from insecure .credentials file - User asks to "secure my wallet" or "migrate to keychain"
- User created a wallet before the keychain update was released
Detect current state
wallet showbash
# 1. Check if a wallet exists at all
nansen wallet list 2>&1
# 2. Check for insecure password stores
ls -la ~/.nansen/.env 2>/dev/null && echo "FOUND: ~/.nansen/.env (insecure)"
ls -la ~/.nansen/wallets/.credentials 2>/dev/null && echo "FOUND: .credentials file (insecure)"
# 3. Try an operation that requires the password (without setting env var)
nansen wallet export default 2>&1Interpret the output:
export- on stderr → needs migration (Path B)
⚠ Password loaded from ~/.nansen/wallets/.credentials - Export succeeds silently → password is in keychain, no migration needed
- JSON error → password not persisted anywhere (Path C or D)
PASSWORD_REQUIRED
Migration paths
Path A: Password in ~/.nansen/.env
(old skill pattern)
~/.nansen/.envThe previous wallet skill told agents to write the password to .
~/.nansen/.envStep 1 — Ask the human for their password:
"Your wallet password is currently stored in ~/.nansen/.env, which is insecure. I can migrate it to your OS keychain. Please confirm the password you used when creating the wallet, or I can read it from ~/.nansen/.env if you authorize it."
Step 2 — Migrate:
The and MUST run in the same shell so the env
var is available to the node process:
sourcenansen wallet securebash
source ~/.nansen/.env 2>/dev/null && nansen wallet secureStep 3 — Verify the password actually decrypts the wallet:
bash
# Unset env var to prove keychain works, then export to verify decryption
unset NANSEN_WALLET_PASSWORD
nansen wallet export default 2>&1If export succeeds (shows private keys), the migration worked. If it shows
, the wrong password was migrated — run and retry with the correct password.
Incorrect passwordnansen wallet forget-passwordStep 4 — Clean up the insecure file:
bash
rm -f ~/.nansen/.envPath B: Password in .credentials
file (auto-saved fallback)
.credentialsThis happens when couldn't access the OS keychain (containers, CI).
wallet createbash
nansen wallet secureIf the keychain is still unavailable (e.g. containerized Linux without D-Bus),
will explain the situation and suggest alternatives.
nansen wallet secureAfter migrating, verify decryption works:
bash
nansen wallet export default 2>&1Path C: Password only in NANSEN_WALLET_PASSWORD
env var
NANSEN_WALLET_PASSWORDbash
# Persist the env var password to keychain
nansen wallet secureThen verify without the env var:
bash
unset NANSEN_WALLET_PASSWORD
nansen wallet export default 2>&1Path D: Password lost entirely
The password cannot be recovered. The wallet's private keys are encrypted with
AES-256-GCM and the password is not stored anywhere recoverable.
Tell the human:
"Your wallet password cannot be recovered. If you have funds in this wallet, they may be inaccessible. You can create a new wallet and transfer any remaining accessible funds."
bash
# Create a fresh wallet (human must provide a new password)
NANSEN_WALLET_PASSWORD="<new_password_from_user>" nansen wallet create --name new-walletPost-migration verification
After any migration, confirm the password was migrated correctly by proving
the keychain password can actually decrypt the wallet:
bash
# Unset env var to prove keychain works
unset NANSEN_WALLET_PASSWORD
# This MUST succeed — it proves the keychain password decrypts the wallet
nansen wallet export default 2>&1If export shows , the wrong password was saved to the
keychain. Fix with:
Incorrect passwordbash
nansen wallet forget-password
NANSEN_WALLET_PASSWORD="<correct_password>" nansen wallet secureIf still shows the warning, the keychain migration did
not succeed — check if the OS keychain service is running ( on Linux,
on macOS).
stderr.credentialssecret-toolsecurityForget password (all stores)
If the user wants to remove their persisted password entirely:
bash
nansen wallet forget-passwordThis clears the password from both OS keychain and file. Future
wallet operations will require env var or re-running
.
.credentialsNANSEN_WALLET_PASSWORDnansen wallet secureCritical rules for agents
- NEVER generate a password — always ask the human
- NEVER store the password in files, memory, logs, or conversation history
- NEVER use flag — interactive prompts break agents
--human - If the human authorizes reading , read it in the same command (
~/.nansen/.env) — do not echo or log the valuesource ~/.nansen/.env && nansen wallet secure - ALWAYS verify after migration with —
nansen wallet export defaultdoes NOT prove the password works (it never loads the password)wallet show