Read Environment Variables in Foundry commands #5039
Unanswered
alymurtazamemon
asked this question in
Q&A
Replies: 1 comment 1 reply
-
@alymurtazamemon #Execute the content of the .env file in the current shell environment
source .env
#You can check if it is working by printing the variable in the terminal
echo $MAINNET_RPC_URL
# run your command with the variables from the .env file
forge create --rpc-url $MAINNET_RPC_URL --private-key $PRIVATE_KEY src/MyContract.sol:MyContract #This is your .env file
MAINNET_RPC_URL="rpc url"
PRIVATE_KEY="your private key" |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is the basic command for deploying the contract. Does anyone have any idea how we can pass the <your_private_key> from the .env file instead of passing it in the command?
I read a discussion where someone suggests writing it to bash script and read from there but this is very insecure.
Beta Was this translation helpful? Give feedback.
All reactions