Skip to content

Conversation

Forostovec
Copy link
Contributor

@Forostovec Forostovec commented Oct 10, 2025

Motivation

Working with hardware wallets in Foundry requires repeatedly passing --mnemonic-index or a full derivation path to forge/cast. This is tedious and error‑prone. Users want to register a hardware wallet once (by alias) and reuse it in forge script --account and related commands, without re-specifying HD params. Additionally, caching the address helps future flows infer --sender automatically.
Closes #11439

Solution

  • Add a persistent hardware wallet registry stored at ~/.foundry/wallets.json.
    • Entry fields: alias, kind (Ledger/Trezor), optional derivation path or mnemonic index, optional cached address.
  • Introduce a new command: cast wallet register to register Ledger/Trezor by alias and optionally cache its address by connecting to the device once.
  • Extend account resolution:
    • forge script --account recognizes aliases from the registry (in addition to existing private key, mnemonic, keystore, AWS/GCP providers).
    • The keystore path behavior remains unchanged and takes precedence; alias resolution is an additive fallback.
  • Update cast wallet list to display registered hardware wallets and a cached address if present.
  • Add Config::foundry_wallets_file() helper and wire the new foundry-wallets registry module.

Example usage:

# Register a Ledger with mnemonic index 0 and cache its address
cast wallet register my-ledger --ledger --mnemonic-index 0 --cache

# Use the alias in forge script
forge script script/Deploy.s.sol --rpc-url $RPC --broadcast --account my-ledger

# List local and registered accounts
cast wallet list

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

feat: allow cast wallet to register Ledger/other HW wallets

2 participants