• Stars
    star
    1,921
  • Rank 23,280 (Top 0.5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Hardhat-based template for developing Solidity smart contracts

Hardhat Template Open in Gitpod Github Actions Hardhat License: MIT

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

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.yml
β”œβ”€β”€ .gitignore
β”œβ”€β”€ .prettierignore
β”œβ”€β”€ .prettierrc.yml
β”œβ”€β”€ .solcover.js
β”œβ”€β”€ .solhint.json
└── hardhat.config.ts

VSCode Integration

This template is IDE agnostic, but for the best user experience, you may want to use it in VSCode alongside Nomic Foundation's Solidity extension.

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 to make this work, you must use your INFURA_API_KEY and your MNEMONIC as GitHub secrets.

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

Usage

Pre Requisites

Before being able to run any command, you need to create a .env file and set a BIP-39 compatible mnemonic as an environment variable. You can follow the example in .env.example. If you don't already have a mnemonic, you can use this website to generate one.

Then, proceed with installing dependencies:

$ pnpm install

Compile

Compile the smart contracts with Hardhat:

$ pnpm compile

TypeChain

Compile the smart contracts and generate TypeChain bindings:

$ pnpm typechain

Test

Run the tests with Hardhat:

$ pnpm test

Lint Solidity

Lint the Solidity code:

$ pnpm lint:sol

Lint TypeScript

Lint the TypeScript code:

$ pnpm lint:ts

Coverage

Generate the code coverage report:

$ pnpm coverage

Report Gas

See the gas usage per unit test and average gas per method call:

$ REPORT_GAS=true pnpm test

Clean

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

$ pnpm clean

Deploy

Deploy the contracts to Hardhat Network:

$ pnpm deploy:contracts

Tasks

Deploy Greeter

Deploy a new instance of the Greeter contract via a task:

$ pnpm task:deployGreeter --network ganache --greeting "Bonjour, le monde!"

Set Greeting

Run the setGreeting task on the Ganache network:

$ pnpm task:setGreeting --network ganache --greeting "Bonjour, le monde!" --account 3

Tips

Syntax Highlighting

If you use VSCode, you can get Solidity syntax highlighting with the hardhat-solidity extension.

Using GitPod

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

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

Local development with Ganache

Install Ganache

$ npm i -g ganache

Run a Development Blockchain

$ ganache -s test

The -s test passes a seed to the local chain and makes it deterministic

Make sure to set the mnemonic in your .env file to that of the instance running with Ganache.

License

This project is licensed under MIT.

More Repositories

1

prb-math

Solidity library for advanced fixed-point math
Solidity
805
star
2

foundry-template

Foundry-based template for developing Solidity smart contracts
Solidity
485
star
3

prb-proxy

Proxy contract to compose Ethereum transactions
Solidity
270
star
4

prb-test

Modern collection of testing assertions and logging utilities for Solidity
Solidity
178
star
5

prb-contracts

Off-the-shelf Solidity smart contracts
Solidity
130
star
6

multisol

CLI application for verifying Solidity contracts on Etherscan
Rust
113
star
7

rust-template

A template for developing Rust projects, with sensible defaults
Rust
76
star
8

awesome-zkp-starter-pack

A curated collection of links for zero-knowledge proof cryptography used in blockchains
69
star
9

btt-examples

Examples for Branching Tree Technique, a simple specification framework for writing structured Solidity tests
Solidity
52
star
10

evm-bn

Convert fixed-point numbers to ethers big numbers and vice-versa.
TypeScript
49
star
11

check-same-sign

Gas golfing the most gas efficient way to check if two integers have the same sign in Solidity
Solidity
46
star
12

foundry-multibuild

GitHub Action for building a Foundry project with a range of Solidity versions
Shell
38
star
13

hardhat-packager

Hardhat plugin for preparing the contract artifacts and the TypeChain bindings for registry deployment
TypeScript
35
star
14

ethsum

Simple Ethereum address checksum tool
JavaScript
33
star
15

solplate

Simple utility for generating boilerplate Solidity contracts
Rust
32
star
16

typescript-template

A template for developing TypeScript project, with sensible defaults
TypeScript
32
star
17

awesome-many-worlds

Curated collection of educational materials on the many-worlds interpretation of quantum mechanics
23
star
18

CoinMarketCap-Desktop

A simple desktop wrapper for CoinMarketCap
JavaScript
21
star
19

github-labels

GitHub labels to use across repositories
Shell
20
star
20

erc2212

Reference implementation for ERC-2212
JavaScript
12
star
21

unchecked-counter

Solidity counter type that bypasses checked arithmetic
Solidity
12
star
22

contractz

Sketchbook for my Ethereum contracts
Solidity
11
star
23

modlizer

Struggling with iOS design patterns? Embrace Modlizer
Swift
11
star
24

create2-repro

Repo to reproduce the inconsistent CREATE2 behavior in Foundry
Solidity
10
star
25

defi-types

TypeChain bindings for DeFi protocols
Solidity
10
star
26

dyi-crypto-taxes

Spreadsheet templates and practical tips and tricks for doing your taxes alone
10
star
27

abdk-gas-estimations

Gas estimations for ADBKMath64x64
Solidity
9
star
28

rust-book-annotations

My absorption of the Rust Book
Rust
8
star
29

javascript-template

A template for developing JavaScript projects, with sensible defaults
JavaScript
7
star
30

typescript-monorepo-template

Dummy monorepo set up with Typescript and Yarn Workspaces
TypeScript
4
star
31

tft

Browser extension that prevents typos by asking you to double-check the content before posting a long tweet",
JavaScript
3
star
32

cryptfolio-scripts

Google Apps Script functions to help with tracking a crypto portfolio in Google Sheets
JavaScript
3
star
33

foundry-expect-emit-bug

Repo to reproduce the bug I ran into while writing tests with Foundry
Solidity
3
star
34

cea-contracts

Base smart contracts used in the default template of Create Eth App
JavaScript
3
star
35

my-eth-app

Default boilerplate code generated by create-eth-app
HTML
3
star
36

hardhat-prb

Hardhat plugins to complement the PRB smart contract libraries
TypeScript
3
star
37

flipper-ui

The frontend app for the users of Flipper.
JavaScript
2
star
38

react-hooks

React Hooks to be shared across my personal projects and packages
JavaScript
2
star
39

web3-react-blobs

Blobs of web3-react code used in the Sablier Interface
JavaScript
2
star
40

forge-coverage-bug

Repo to reproduce the bug in the forge coverage command
Solidity
2
star
41

PaulRBerg.github.io

My personal preferences
JavaScript
2
star
42

xstate-useActor-bug

xstate useActor bug
TypeScript
2
star
43

prb-proxy-frontend

Landing page for PRBProxy
TypeScript
2
star
44

eslint-config

Eslint config to be shared across my personal projects and packages
JavaScript
2
star
45

airdropx

Firebase backend for the AirdropX Telegram bot
JavaScript
1
star
46

learn-plasma-rss

RSS feed for Plasma resources
JavaScript
1
star
47

paulrberg-labelsync

Dummy repo for label-sync.com
1
star
48

sketchpad

Personal repo for learning, logs and constants
JavaScript
1
star
49

dfe

Browser extension that hides the price of Ether
JavaScript
1
star
50

cea-template

The official base template for Create Eth App.
HTML
1
star
51

hardhat-ignition-basic

Dummy project for going through the [email protected] basic tutorial
TypeScript
1
star
52

vscode-dictionary

Personal dictionary for vscode-spell-checker
1
star
53

buidler-invalid-opcode

Reproduces the ganache-cli invalid opcode bug
TypeScript
1
star
54

yarn-rc34-error

Dummy project to reproduce the errors I encountered with [email protected]
JavaScript
1
star
55

ethiasi

Landing page for the first Ethereum event in Iasi, Romania
CSS
1
star
56

codebase-go

Personal repo for learning, logs and constants related to golang.
Go
1
star
57

ethereum-signatures-progress

A collection of links and resources I collected in order to implement EIP-191 and EIP-712 into geth.
1
star