Hardhat Environment Template with a Professional Basic Setup
Explore the docs »
Report Bug
·
Request Feature
Table of Contents
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.
- 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).
Package manager installation (npm)
- npm
npm install npm@latest -g
-
Clone the repo
git clone https://github.com/uri1001/tgp-hardhat.git
-
Install NPM packages
npm install
-
Rename
.env.samplefile to.envmv ./.env.sample ./.env
-
Introduce to
.envthe wallet & API keysmasterPrivateKey = 'wallet-private-key' backupPrivateKey = 'wallet-private-key' infuraAPIKey = 'API-key' alchemyAPIKey = 'API-key' . . .
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
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>
Lint All Contracts
sh npm run solhint
Format All Code
sh npm run prettier:solidity
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
Official Documentation: Documentation
Official Documentation: Documentation
Cheatsheet: Cheatsheet
Official Documentation: Documentation
Contract Testing Framework - Mocha: Documentation
Contract Testing Library - Chai: Documentation
Hardhat Testing Documentation: Documentation
Hardhat Toolbox: Documentation
Hardhat Ethers: Documentation
Hardhat Chai Matchers: Documentation
Hardhat Network Helpers: Documentation
Hardhat Etherscan: Documentation
Hardhat Gas Reporter: Documentation
Hardhat Solidity Coverage: Documentation
Hardhat Typechain: Documentation
Hardhat Contract Sizer: Documentation
Hardhat Storage Layout: Documentation
Official Documentation: Documentation
Contracts Wizard: Wizard
Official Documentation: Documentation
Supported Rules: Rules
Official Documentation: Documentation
Distributed under the MIT License. See LICENSE.txt for more information.