foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.04k stars 1.65k forks source link

Generate multiple keypairs for mnemonic #1718

Closed nikkolasg closed 2 months ago

nikkolasg commented 2 years ago

Component

Anvil

Describe the feature you would like

It would be nice to have the ability to ask Anvil to spit out the private keys into a JSON file or stg as to enable programmatic interaction with it (instead of manually copy paste the key(s)).

Additional context

No response

mattsse commented 2 years ago

I'm not in favor of support this via rpc calls or anything that needs to interact with a running node, but I agree that would be a nice feature to have.

we have the cast wallet command which generates single keypairs, I'd propose we add support for mnemonic key generation, I don't think we have something like this yet, right @onbjerg ?

something like cast wallet mnemonic "...." with an --anvil flag to dump the default keys?

nikkolasg commented 2 years ago

I'm not in favor of support this via rpc calls or anything that needs to interact with a running node

Oh no I was thinking stg far more simpler like anvil --secrets-to keys.json when you start anvil or stg. That way, when you start anvil you can programmatically get the already-funded private keys easily (instead of doing the parsing yourself).

mattsse commented 2 years ago

right,

anvil --secrets-to keys.json that makes sense, but will also need some additional arguments, like mnemonic, hdpath, index perhaps, (same that anvil supports)

I think this would be useful on its own and is not limited to anvil.

we could add this to cast wallet which is more fitting I believe, but could then reuse this for anvil as well.

nikkolasg commented 2 years ago

anvil --secrets-to keys.json that makes sense, but will also need some additional arguments, like mnemonic, hdpath, index perhaps, (same that anvil supports)

I guess in the end, what this feature is about is get all the info anvil prints out in a easily parsable fashion instead of handwriting regexp, so maybe anvil --info-out info.json or stg to also add the mnemonics etc. Also a good idea for cast wallet for sure yeah !

onbjerg commented 2 years ago

Currently cast wallet only operates on a single JSON keystore, but it is also a bit broken last time I tried it. The details are in another issue related to keystores: #926

gakonst commented 2 years ago

@robertabbott check this out

PatrickAlphaC commented 1 year ago

Additional context: https://github.com/foundry-rs/foundry/issues/3818

zerosnacks commented 2 months ago

Marking as complete, requested feature is available using anvil --config-out and loading a mnemonic in an encrypted keystore was added here: https://github.com/foundry-rs/foundry/issues/3818