Skip to content

Latest commit

 

History

History
99 lines (63 loc) · 3.01 KB

README.md

File metadata and controls

99 lines (63 loc) · 3.01 KB

hardhat-foundry-starter-kit

This is an up-to-date template repository while working with hardhat (typescript based) and foundry.

Recommended vscode extensions

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.

How to start

  1. Create .env file in the root of the repo with the following env variables:

    • SEPOLIA_PRIVATE_KEYS - need to be created freshly
    • LOCALHOST_PRIVATE_KEYS - can be obtained from local devnet (fired up with hardhat or foundry)
  2. Install dependencies

    npm install

How to add Foundry to a hardhat project

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:

  1. Use hardhat-foundry for setup

  2. 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)

General commands

Start local devnet

  • with hardhat: npx hardhat node
  • with foundry: anvil

Basic hardhat commands

  1. Compile contract

    npx hardhat compile
  2. Test contract

    npx hardhat test
    
    # Test with coverage table
    npx hardhat coverage
  3. Deploy contract to local testnet

    npx hardhat ignition deploy ignition/modules/* --network localhost

Basic foundry commands

  1. Compile contract

    forge build
  2. Test contract

    # Test with gas-report output
    forge test --gas-report
  3. Get coverage table

    forge coverage
  4. Deploy contract to local testnet

    forge script ./foundry/script/Faucet.s.sol:FaucetDeploymentScript --rpc-url localhost --broadcast