Skip to content

feature(cast wallet list): extend or add a new command to support listing accounts from a mnemonic #12676

@leovct

Description

@leovct

Component

Cast

Describe the feature you would like

Description

cast wallet list currently lists accounts stored in the keystore directory, but there is no built-in way to list derived accounts from a given mnemonic. For debugging and development workflows, it would be helpful to generate and inspect multiple addresses (and optionally private keys) directly from a mnemonic.

Current workaround:

MNEMONIC="code code code code code code code code code code code quality"
ACCOUNTS=3
for i in $(seq 1 $ACCOUNTS); do
  pk=$(cast wallet private-key --mnemonic "$MNEMONIC" --mnemonic-index "$((i - 1))")
  address=$(cast wallet address --private-key "$pk")
  echo '{"address":"'$address'","private_key":"'$pk'"}'
done | jq --slurp

which produces:

[
  {
    "address": "0x85dA99c8a7C2C95964c8EfD687E95E632Fc533D6",
    "private_key": "0x42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa"
  },
  {
    "address": "0x125FB391bA829e0865963D3B91711610049a9e78",
    "private_key": "0x0903a9a721167e2abaa0a33553cbeb209dc9300d28e4e4d6d2fac2452f93e357"
  },
  {
    "address": "0x964ec59D0E05Db08440c822d7C588e63BBDE8c4e",
    "private_key": "0x6421222a9964cbe1b411191dcac1afda173ed99346c47302c6fe88f65d83583e"
  }
]

Proposed Enhancement

Extend the existing cast wallet list or introduce a new subcommand, for example:

cast wallet list --mnemonic "<mnemonic>" --accounts N

By default, it would only output addresses, for security reasons. It could take an optional flag, --insecure, to also include the corresponding private keys.

If the maintainers consider this feature useful, I’d be happy to work on the implementation! :)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-castCommand: castT-featureType: featurefirst issueA good way to start contributing

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions