|
@@ -1,22 +1,77 @@
|
|
|
-# Solidity Template
|
|
|
+# Hardhat Template [![Github Actions][gha-badge]][gha] [![Hardhat][hardhat-badge]][hardhat] [![License: MIT][license-badge]][license]
|
|
|
|
|
|
-My favorite setup for writing Solidity smart contracts.
|
|
|
+[gha]: https://github.com/paulrberg/hardhat-template/actions
|
|
|
+[gha-badge]: https://github.com/paulrberg/hardhat-template/actions/workflows/ci.yml/badge.svg
|
|
|
+[hardhat]: https://hardhat.org/
|
|
|
+[hardhat-badge]: https://img.shields.io/badge/Built%20with-Hardhat-FFDB1C.svg
|
|
|
+[license]: https://opensource.org/licenses/MIT
|
|
|
+[license-badge]: https://img.shields.io/badge/License-MIT-blue.svg
|
|
|
|
|
|
-- [Hardhat](https://github.com/nomiclabs/hardhat): compile and run the smart contracts on a local development network
|
|
|
-- [TypeChain](https://github.com/ethereum-ts/TypeChain): generate TypeScript types for smart contracts
|
|
|
+A Hardhat-based template for developing Solidity smart contracts, with sensible defaults.
|
|
|
+
|
|
|
+- [Hardhat](https://github.com/nomiclabs/hardhat): compile, run and test smart contracts
|
|
|
+- [TypeChain](https://github.com/ethereum-ts/TypeChain): generate TypeScript bindings for smart contracts
|
|
|
- [Ethers](https://github.com/ethers-io/ethers.js/): renowned Ethereum library and wallet implementation
|
|
|
-- [Solhint](https://github.com/protofire/solhint): linter
|
|
|
+- [Solhint](https://github.com/protofire/solhint): code linter
|
|
|
- [Solcover](https://github.com/sc-forks/solidity-coverage): code coverage
|
|
|
- [Prettier Plugin Solidity](https://github.com/prettier-solidity/prettier-plugin-solidity): code formatter
|
|
|
|
|
|
-This repo is a GitHub template, so to start using it, click the "Use this template" button at the top of the page.
|
|
|
+## Getting Started
|
|
|
+
|
|
|
+Click the [`Use this template`](https://github.com/paulrberg/hardhat-template/generate) 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](https://hardhat.org/tutorial) and the [Hardhat
|
|
|
+Docs](https://hardhat.org/docs). You might be in particular interested in reading the [Testing Contracts](https://hardhat.org/tutorial/testing-contracts) section.
|
|
|
+
|
|
|
+### Sensible Defaults
|
|
|
+
|
|
|
+This template comes with sensible default configurations in the following files:
|
|
|
+
|
|
|
+```text
|
|
|
+├── .commitlintrc.yml
|
|
|
+├── .editorconfig
|
|
|
+├── .eslintignore
|
|
|
+├── .eslintrc.yml
|
|
|
+├── .gitignore
|
|
|
+├── .prettierignore
|
|
|
+├── .prettierrc.yml
|
|
|
+├── .solcover.js
|
|
|
+├── .solhintignore
|
|
|
+├── .solhint.json
|
|
|
+├── .yarnrc.yml
|
|
|
+└── hardhat.config.ts
|
|
|
+```
|
|
|
+
|
|
|
+### 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 se your `INFURA_API_KEY` and your `MNEMONIC` as GitHub secrets.
|
|
|
+
|
|
|
+You can edit the CI script in [.github/workflows/ci.yml](./.github/workflows/ci.yml).
|
|
|
+
|
|
|
+### Conventional Commits
|
|
|
+
|
|
|
+This template enforces the [Conventional Commits](https://www.conventionalcommits.org/) standard for git commit messages.
|
|
|
+This is a lightweight convention that creates an explicit commit history, which makes it easier to write automated
|
|
|
+tools on top of.
|
|
|
+
|
|
|
+### Git Hooks
|
|
|
+
|
|
|
+This template uses [Husky](https://github.com/typicode/husky) to run automated checks on commit messages, and [Lint Staged](https://github.com/okonet/lint-staged) to automatically format the code with Prettier when making a git commit.
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
### Pre Requisites
|
|
|
|
|
|
-Before running any command, you need to create a `.env` file and set a BIP-39 compatible mnemonic as an environment
|
|
|
-variable. Follow the example in `.env.example`. If you don't already have a mnemonic, use this [website](https://iancoleman.io/bip39/) to generate one.
|
|
|
+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](https://iancoleman.io/bip39/) to generate one.
|
|
|
|
|
|
Then, proceed with installing dependencies:
|
|
|
|
|
@@ -34,12 +89,20 @@ $ yarn compile
|
|
|
|
|
|
### TypeChain
|
|
|
|
|
|
-Compile the smart contracts and generate TypeChain artifacts:
|
|
|
+Compile the smart contracts and generate TypeChain bindings:
|
|
|
|
|
|
```sh
|
|
|
$ yarn typechain
|
|
|
```
|
|
|
|
|
|
+### Test
|
|
|
+
|
|
|
+Run the tests with Hardhat:
|
|
|
+
|
|
|
+```sh
|
|
|
+$ yarn test
|
|
|
+```
|
|
|
+
|
|
|
### Lint Solidity
|
|
|
|
|
|
Lint the Solidity code:
|
|
@@ -56,14 +119,6 @@ Lint the TypeScript code:
|
|
|
$ yarn lint:ts
|
|
|
```
|
|
|
|
|
|
-### Test
|
|
|
-
|
|
|
-Run the Mocha tests:
|
|
|
-
|
|
|
-```sh
|
|
|
-$ yarn test
|
|
|
-```
|
|
|
-
|
|
|
### Coverage
|
|
|
|
|
|
Generate the code coverage report:
|
|
@@ -96,10 +151,12 @@ Deploy the contracts to Hardhat Network:
|
|
|
$ yarn deploy --greeting "Bonjour, le monde!"
|
|
|
```
|
|
|
|
|
|
-## Syntax Highlighting
|
|
|
+## Tips
|
|
|
+
|
|
|
+### Syntax Highlighting
|
|
|
|
|
|
-If you use VSCode, you can get Solidity syntax highlighting via the [vscode-solidity](https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity) extension.
|
|
|
+If you use VSCode, you can get Solidity syntax highlighting with the [vscode-solidity](https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity) extension.
|
|
|
|
|
|
## License
|
|
|
|
|
|
-[Unlicense](./LICENSE.md)
|
|
|
+[MIT](./LICENSE.md) © Paul Razvan Berg
|