Block: 39

Timestamp: 12:02:02

AuditProfile

Security blog

Foundry vs .env

Using a private key in the .env file to deploy and test your smart contracts is not safe, even if you put it in .gitignore later!

Foundry lets you do it in the most secure way!

Let's dive deep!

Private keys can now be stored in a special encrypted file under a password on your computer. The whole process takes only a couple of minutes.

First of all open your command line and run

`cast wallet import defautKey --interactive`

Here you should paste your private key. Let's take an Anvil account key as an example:

0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

No need to worry! Your private key is not visible! Just press enter. Now you should create a password for it:

And finally, you'll get a generated address. Remember it or save it for future use:

To check that it has been created correctly, run:

`cast wallet list`

Now when you'll want to deploy your contract you can run the next command. AddressKey is an address you received after creating a wallet.

The console will then ask you to enter your password.

You got no code editor logs or unsafe .env files with you private key info!

Stay safe! Be smart!

#foundry

#env

Connent with me:

Регистрация прошла успешно! Спасибо за внимание!

loader