Closed krabat-h closed 1 year ago
Hi @krabat-h, you also need to ensure that you have a MNEMONIC set in the .env
file. A mnemonic is a 12 or 24-word string that can generate multiple Ethereum wallets.
Also check out the Hardhat reference.
Hi @krabat-h, did the reference link above solve your problem? Can we close this issue?
I ran in to same issue when i clone the project and replace .env.example with .env file. I debug and found that it is because environment variable DOTENV_CONFIG_PATH is set to "./.env.example".
I fix that by change the DOTENV_CONFIG_PATH variable in package.json and it work.
Thanks for the additional info, @maksir98.
Tagging @ahmedali8 since he was the one who added that postinstall
script.
The postinstall
script runs immediately after yarn install
, during which the environment variable DOTENV_CONFIG_PATH
is already set to "./.env.example"
. This is done to ensure that the necessary INFURA_API_KEY
and MNEMONIC
variables exist in the environment.
However, setting DOTENV_CONFIG_PATH
to ".env"
in the postinstall
script can cause issues since there is no .env
file present when the repo is initially cloned or during CI (Github Actions).
To address this, a possible solution is to manually set DOTENV_CONFIG_PATH
to ".env"
when creating a new repo from this template, but make sure to add the environment variables in ci.yml
and Github secrets
in order to make the CI action pass. @PaulRBerg, what are your thoughts on this approach? It might also be helpful to add this information to the README for future reference.
Thanks for your feedback, Ahmed.
make sure to add the environment variables in
ci.yml
and Github secrets in order to make the CI action pass
You mean add the dummy values from .env.example
in the CI environment?
You mean add the dummy values from
.env.example
in the CI environment?
To clarify, the variables INFURA_API_KEY
and MNEMONIC
are the ones being referred to.
Yes, but you mean adding the dummy values from .env.example
in GitHub secrets, don't you?
Yes, but you mean adding the dummy values from
.env.example
in GitHub secrets, don't you?
Both dummy and real values can be used as Github secrets, based on personal preference.
Solved, Thank you all!
I have set the .env file (mv .env.example .env):
When I execute
yarn install
, I got:Error: Please set your MNEMONIC in a .env file at Object. (/Users/luguanghong/work/base/Base-wallet-contract/hardhat.config.ts:16:9)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module.m._compile (/Users/luguanghong/work/base/Base-wallet-contract/node_modules/ts-node/src/index.ts:1618:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Object.require.extensions. [as .ts] (/Users/luguanghong/work/base/Base-wallet-contract/node_modules/ts-node/src/index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at importCsjOrEsModule (/Users/luguanghong/work/base/Base-wallet-contract/node_modules/hardhat/src/internal/core/config/config-loading.ts:28:20)
yarn version: 3.2.1