Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to Keystore implementation for deployer accounts in foundry projects. #812

Open
1 task done
JacobHomanics opened this issue Apr 14, 2024 · 3 comments
Open
1 task done

Comments

@JacobHomanics
Copy link
Contributor

Is there an existing issue for this?

Which method was used to setup Scaffold-ETH 2 ?

npx create-eth@latest

Current Behavior

Currently, SE2 stores private keys in .env files. This is dangerous as it may lead to accidental leaking of private keys through git commits or showing the file on a local machine to unwelcome eyes. However, that was the best solution for awhile...Until now!!

Expected Behavior

Thanks to rplusq's work on Foundry, we successfully have a solution, through Keystores, to the issues present with the .env implementations.

Keystores are integrated through https://eips.ethereum.org/EIPS/eip-2335 to securely hash a private key.

Foundry's integration allows you to store a private within a Keystore, lock the contents behind a user defined password, and even if the password is known, you would still need access to the creator's local machine to access the private key.

Here is a demo of a SE2 Foundry project implementing the new functionality:
https://github.com/Hotmanics/scaffold-eth-2-foundry-keystore-demo

In the demo yarn generate creates a new wallet and creates a keystore using cast wallet import ${randomWallet.address} --private-key ${randomWallet.privateKey}, then yarn deploy accesses the keystore through some black magic to call the deploy script with the private key from within the keystore!

The developer's experience stays exactly the same and experiences the exact same results, aside from the migration from .env to keystores.

Please let me know your thoughts and feel free to suggest any improvements to the implementation!

Thank you!!

Steps To Reproduce

No response

Anything else?

No response

@JacobHomanics
Copy link
Contributor Author

@PatrickAlphaC's explanation of the nuts and bolts of the core technology involved:
https://www.youtube.com/watch?v=VQe7cIpaE54

@PatrickAlphaC
Copy link

We love this issue

@carletex
Copy link
Member

Hey @Hotmanics thanks for this! I think this is the way to go.

It feels that we are going to have foundry as a default in SE2, and having hardhat as an option in the NPX installer (We just migrated the CLI branch to https://github.com/scaffold-eth/create-eth)

So we'll clean / update the Foundry branch before merging, and let's include this too.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants