mkdir project
cd project
yarn init -2
yarn config set nodeLinker node-modules
yarn add hardhat --dev
rm README.md
yarn hardhat init
yarn add mocha --dev
code .
.mocharc.json file:
{
"require": "hardhat/register",
"timeout": 40000,
"_": ["tests/**/*.ts"]
}
Suggested renaming:
// Renaming "test" folder
mv test tests
If using Yarn Berry with PnP:
// Setting up yarn sdk for vscode
yarn dlx @yarnpkg/sdks vscode
// Press ctrl+shift+p in a TypeScript file
// Choose "Select TypeScript Version"
// Pick "Use Workspace Version"
hardhat.config.ts file:
{
const config: HardhatUserConfig = {
...
paths: { tests: "tests" },
...
}
}
tsconfig.json file:
...
"include": ["./scripts", "./tests", "./typechain"],
"files": ["./hardhat.config.ts"],
...
Create env file in root project folder
.env file:
MNEMONIC="here is where your twelve words mnemonic should be put my friend"
PRIVATE_KEY="<your private key here if you don't have a mnemonic seed>"
INFURA_API_KEY="********************************"
INFURA_API_SECRET="********************************"
ALCHEMY_API_KEY="********************************"
ETHERSCAN_API_KEY="********************************"