Skip to content

uri011/hardhat-project

Repository files navigation

Contributors Forks Issues MIT License


Logo

Hardhat Environment Template

Hardhat Environment Template with a Professional Basic Setup
Explore the docs »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Project Initialization
  3. Documentation
  4. Resources
  5. License

1. About The Project

Hardhat Environment Template with a Professional Basic & Customized Setup

The goal is to create a Hardhat basic enviroment setup that reduces the amount of time needed to create a new Solidity project. Achieved by implementing complex processes with tasks & scripts. Includes formatting, linting and source control tools with their respective rules.

1.1. Features

  • Generic Scripts
    • Deploy - contract deployment generic script
    • Delegate - ERC20Votes standard delegation generic script
    • Mint - ERC20 standard mint generic script
    • Burn - ERC20 standard burn generic script
    • Vote - TokenizedBallot contract voting generic script
  • Generic Tasks
    • Accounts - Selected Network Accounts Information
    • Info - Selected Address Basic Information
    • Network - Selected Network Information
  • Wide Network Support
    • Ethereum - mainnet & goerli
    • Polygon - polygon & polygonMumbai
    • Arbitrum - arbitrumOne & arbitrumGoerli
    • Optimism - optimism & optimismGoerli
    • BSC - bsc & bscTestnet
    • Cronos - cronos & cronosTestnet
  • Hardhat Official Plugins
    • Hardhat Toolbox - commonly used packages and Hardhat plugins
    • Hardhat Ethers - wrapped version of ethers.js adapted to Hardhat (installed with Toolbox plugin)
    • Hardhat Chai Matchers - EVM specific capabilities for Chai (installed with Toolbox plugin)
    • Hardhat Network Helpers - helper functions to interact with Hardhat network (installed with Toolbox plugin)
    • Hardhat Etherscan - contract verification service (installed with Toolbox plugin)
  • Hardhat Community Plugins
    • Hardhat Gas Reporter - gas usage related reports (installed with Toolbox plugin)
    • Hardhat Solidity Coverage - code coverage (installed with Toolbox plugin)
    • Hardhat Typechain - Typescript bindings for contracts (installed with Toolbox plugin)
    • Hardhat Contract Sizer - calculate compiled contract size
    • Hardhat Storage Layout - generate contract storage layout
  • Solidity Linting with Solhint
  • Code Formatting with Prettier
  • Code Formatting Enforcement with Husky

See the open issues for a full list of proposed features (and known issues).

(back to top)

2. Project Initialization

2.1. Prerequisites

Package manager installation (npm)

  • npm
    npm install npm@latest -g

2.2. Installation

  1. Clone the repo

    git clone https://github.com/uri1001/tgp-hardhat.git
  2. Install NPM packages

    npm install
  3. Rename .env.sample file to .env

    mv ./.env.sample ./.env
  4. Introduce to .env the wallet & API keys

    masterPrivateKey = 'wallet-private-key'
    backupPrivateKey = 'wallet-private-key'
    
    infuraAPIKey = 'API-key'
    alchemyAPIKey = 'API-key'
    
    .
    .
    .

(back to top)

3. Documentation

3.1. Hardhat Tasks

Get Information sh npx hardhat

Usage: hardhat [GLOBAL OPTIONS] [TASK OPTIONS]

GLOBAL OPTIONS:

--config              A Hardhat config file.
--emoji               Use emoji in messages.
--help                Shows this message, or a task's help if its name is provided
--max-memory          The maximum amount of memory that Hardhat can use.
--network             The network to connect to.
--show-stack-traces   Show stack traces.
--tsconfig            A TypeScript config file.
--verbose             Enables Hardhat verbose logging
--version             Shows hardhat's version.

AVAILABLE TASKS:

check         Check whatever you need
clean         Clears the cache and deletes all artifacts
compile       Compiles the entire project, building all artifacts
console       Opens a hardhat console
flatten       Flattens and prints contracts and their dependencies
help          Prints this message
node          Starts a JSON-RPC server on top of Hardhat Network
run           Runs a user-defined script after compiling the project
test          Runs mocha tests

To get help for a specific task run: npx hardhat help

3.2. Compilation, Deployment & Verification

Compile Contracts sh npx hardhat compile

Deploy Contracts sh npx hardhat run --network <network> scripts/<deploy_script>.ts

Verify Contracts sh npx hardhat verify --network <network> <contract-address> <constructor-arguments>

3.3. Linting & Formatting

Lint All Contracts sh npm run solhint

Format All Code sh npm run prettier:solidity

(back to top)

4. Resources

4.1. Solidity Documentation

Official Documentation: Documentation

Official Structure of Contract: Structure

Official Language Grammar: Grammar

Official Security Considerations: Security

Official Storage Layout fo State Variables: Storage

Official NatSpec: NatSpec

Official Style Guide: Style

4.2. TypeScript Documentation

Official Documentation: Documentation

4.3. Ethers Documentation

Official Documentation: Documentation

Cheatsheet: Cheatsheet

4.4. Hardhat Documentation

Official Documentation: Documentation

Contract Testing Framework - Mocha: Documentation

Contract Testing Library - Chai: Documentation

Hardhat Testing Documentation: Documentation

4.4.1. Hardhat Official Plugins

Hardhat Toolbox: Documentation

Hardhat Ethers: Documentation

Hardhat Chai Matchers: Documentation

Hardhat Network Helpers: Documentation

Hardhat Etherscan: Documentation

4.4.2. Hardhat Community Plugins

Hardhat Gas Reporter: Documentation

Hardhat Solidity Coverage: Documentation

Hardhat Typechain: Documentation

Hardhat Contract Sizer: Documentation

Hardhat Storage Layout: Documentation

4.5. Openzeppelin Documentation

Official Documentation: Documentation

Contracts Wizard: Wizard

4.6. Lint Tool

Official Documentation: Documentation

Supported Rules: Rules

4.7. Format Tool

Official Documentation: Documentation

(back to top)

5. License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

About

An advanced Hardhat project set up

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published