Closed pmdaly closed 2 years ago
Adding a .env
file that's not a proper bash script (as is .dapprc) but a simple .env file should be easy enough. There is a relevant crate for this.
That being said, perhaps it's better to do source .env && ...
and use makefile
Adding a
.env
file that's not a proper bash script (as is .dapprc) but a simple .env file should be easy enough. There is a relevant crate for this.That being said, perhaps it's better to do
source .env && ...
and use makefile
Finally. Yes. Instead though upgrade to justfile, https://github.com/sambacha/foundry-scripts/blob/master/justfile
Bid Makefile adios yes.
This justfile will correctly load your .env file. It also offers some convenience scripts.
Just
just build
Just want to second that .env
file support would be great.
Have started using foundry two months ago and already faced projects using:
forge test --fork-url https://eth-mainnet.alchemyapi.io/v2/<apiKey> --fork-block-number 15006652 -vv
and similar)All of these seem to essentially be workarounds for getting .env
into foundry
/ foundry.toml
(as i get it while the toml supports env variables [rpc_endpoints] mainnet = "${RPC_MAINNET}"
you have to source them before as it doesn't read .env
automatically.
Would love to see native .env
support to increase consistency across projects & decrease custom build solutions where ppl can just run foundry test
and things work.
Component
Forge
Describe the feature you would like
It's common to use a different RPC per project and to additionally not want it public. The current method for supplying an rpc is to either add it to foundry.toml, set it in the session, or set it in some profile config file like .zshrc, .profile etc. It's common to version control the toml file so placing the rpc in there isn't ideal and using a globally set env var makes it messy to work with multiple projects.
Proposed solution: in addition to checking default config, foundry.toml and env vars, add an additional check to see if vars are stored in the project's .env file if it exists. I'm not even sure the rpc should be an option in the toml file.
Additional context
No response