This is an up-to-date template repository while working with hardhat (typescript based) and foundry.
There was a question during the workshop, how I made the brackets colorful. This is now built-in to VSCode directly and can be activated with the following setting @id:editor.bracketPairColorization.enabled @id:editor.guides.bracketPairs
. For colorful indentation use this extension.
Note: In order that ESLint and Prettier extension work as expected I also added the .vscode
folder to the repo with the respective settings. It is still possible that something does not work as vscode settings are sometimes tricky.
-
Create
.env
file in the root of the repo with the following env variables:SEPOLIA_PRIVATE_KEYS
- need to be created freshlyLOCALHOST_PRIVATE_KEYS
- can be obtained from local devnet (fired up with hardhat or foundry)
-
Install dependencies
npm install
Before you start you need to install foundry.
Note: Foundry/forge-std was already added as submodule to THIS repository. You do not need to execute one of the below commands. This was just added to showcase the possibilities you have when you work on a fresh repository/project.
After installation you have two possibilities:
-
Add foundry git submodule manually (resulting in a cleaner structure)
git submodule add https://github.com/foundry-rs/forge-std foundry/lib/forge-std
- create
foundry.toml
in the root of the repository(see here for configuration settings) - be sure to configure path settings (see
foundry.toml
in this repo)
- create
- with hardhat:
npx hardhat node
- with foundry:
anvil
-
Compile contract
npx hardhat compile
-
Test contract
npx hardhat test # Test with coverage table npx hardhat coverage
-
Deploy contract to local testnet
npx hardhat ignition deploy ignition/modules/* --network localhost
-
Compile contract
forge build
-
Test contract
# Test with gas-report output forge test --gas-report
-
Get coverage table
forge coverage
-
Deploy contract to local testnet
forge script ./foundry/script/Faucet.s.sol:FaucetDeploymentScript --rpc-url localhost --broadcast