ahmedali8
hardhat-js-starterkit
JavaScript

hardhat environment starterkit for testing and deployment of smart contracts

Last updated Feb 13, 2026
16
Stars
2
Forks
0
Issues
0
Stars/day
Attention Score
4
Language breakdown
No language data available.
โ–ธ Files click to expand
README

Hardhat Starterkit (JavaScript) [![Open in Gitpod][gitpod-badge]][gitpod] [![Github Actions][gha-badge]][gha] [![Hardhat][hardhat-badge]][hardhat]

[gitpod]: https://gitpod.io/#https://github.com/ahmedali8/hardhat-js-starterkit [gitpod-badge]: https://img.shields.io/badge/Gitpod-Open%20in%20Gitpod-FFB45B?logo=gitpod [gha]: https://github.com/ahmedali8/hardhat-js-starterkit/actions [gha-badge]: https://github.com/ahmedali8/hardhat-js-starterkit/actions/workflows/ci.yml/badge.svg [hardhat]: https://hardhat.org/ [hardhat-badge]: https://img.shields.io/badge/Built%20with-Hardhat-FFDB1C.svg

A Hardhat-based template for developing Solidity smart contracts, with sensible defaults.

Inspiration - Hardhat Template and Hardhat TS Template

  • Hardhat: compile, run and test smart
contracts
  • Ethers: renowned Ethereum library
and wallet implementation code linter code formatter

Getting Started

Click the Use this template button at the top of the page to create a new repository with this repo as the initial state.

Features

This template builds upon the frameworks and libraries mentioned above, so for details about their specific features, please consult their respective documentations.

For example, for Hardhat, you can refer to the Hardhat Tutorial and the Hardhat Docs. You might be in particular interested in reading the Testing Contracts section.

Sensible Defaults

This template comes with sensible default configurations in the following files:

โ”œโ”€โ”€ .editorconfig
โ”œโ”€โ”€ .eslintignore
โ”œโ”€โ”€ .eslintrc.js
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ .prettierignore
โ”œโ”€โ”€ .prettierrc
โ”œโ”€โ”€ .solcover.js
โ”œโ”€โ”€ .solhintignore
โ”œโ”€โ”€ .solhint.json
โ”œโ”€โ”€ .yarnrc.yml
โ””โ”€โ”€ hardhat.config.js

GitHub Actions

This template comes with GitHub Actions pre-configured. Your contracts will be linted and tested on every push and pull request made to the main branch.

Note though that by default it injects .env.example env variables into github action's $GITHUB_ENV.

You can edit the CI script in .github/workflows/ci.yml.

Usage

Pre Requisites

Before running any command, you need to create a .env file and set all necessary environment variables. Follow the example in .env.example. You can either use mnemonic or individual private keys by setting

$ ACCOUNT_TYPE="MNEMONIC" (Default)
or
$ ACCOUNTTYPE="PRIVATEKEYS"

If you don't already have a mnemonic, use this mnemonic-website to generate one Or if you don't already have a private key, use this privatekey-website to generate one.

Then, proceed with installing dependencies:

$ yarn install

Run a Hardhat chain

To run a local network with all your contracts in it, run the following:

$ yarn chain

Compile

Compile the smart contracts with Hardhat:

$ yarn compile

Test

Run the tests with Hardhat:

$ yarn test

or

$ yarn test:gas # shows gas report and contract size

or

$ yarn test:trace # shows logs + calls

or

$ yarn test:fulltrace # shows logs + calls + sloads + sstores

Optional:

  • See the actual fiat currency rates by setting your coingecko api key from
here in .env file or command.
  • Set custom gas price (gwei) in .env file or command or let it automatically
fetched by ethgasstationapi.
$ GAS_PRICE=20
$ COINMARKETCAPAPIKEY="yourapikey"

Lint Solidity

Lint the Solidity code:

$ yarn lint:sol

Forking mainnet

Starts a local hardhat chain with the state of the last mainnet block

$ yarn fork

Coverage

Generate the code coverage report:

$ yarn coverage

Clean

Delete the smart contract artifacts, the coverage reports and the Hardhat cache:

$ yarn clean

Deploy

Deploy the contracts to Hardhat Network:

$ yarn deploy

Deploy the contracts to a specific network, such as the Goerli testnet:

$ yarn deploy:network goerli

Generate Natspec Doc

Generate natspec documentation for your contracts by runing

$ yarn dodoc

For more information on Natspec click here and for dodoc repo click here

View Contracts Size

$ yarn size

or turn on for every compile

$ CONTRACT_SIZER=true

Verify Contract

Manual Verify

$ npx hardhat verify --network <network> DEPLOYEDCONTRACTADDRESS "Constructor argument 1" "Constructor argument 2"

For complex arguments you can refer here

$ npx hardhat verify --contract contracts/CONTRACTNAME.sol:CONTRACTNAME --network <network> --constructor-args arguments.js DEPLOYEDCONTRACTADDRESS

Verify Contract Programmatically

Verify the contract using verifyContract function in verify.js

Set block explorer api key in .env file or using command, refer to .env.example for more insight.

Example deploy script with verifyContract function is here

Syntax Highlighting

If you use VSCode, you can enjoy syntax highlighting for your Solidity code via the vscode-solidity extension.

Using GitPod

GitPod is an open-source developer platform for remote development.

To view the coverage report generated by yarn coverage, just click Go Live from the status bar to turn the server on/off.

Contributing

Contributions are always welcome! Open a PR or an issue!

Thank You!

Resources

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท ahmedali8/hardhat-js-starterkit ยท Updated daily from GitHub