This repository contains a sample project that you can use as the starting point for your Ethereum project. It's a modified typescript version of the Hardhat Hackathon javascript boilerplate that uses an OpenZeppelin ERC-20 token instead of a proprietary token.
The first things you need to do are cloning this repository and installing its dependencies:
git clone https://github.com/andyjagoe/hardhat-dapp.git
cd hardhat-dapp
npm install
Once installed, run Hardhat's testing network:
npx hardhat node
Then, in a new terminal, go to the repository's root folder and run this to deploy your contract:
npx hardhat run scripts/deploy.ts --network localhost
Finally, run the frontend with:
cd frontend
npm install
npm start
Note: There's an issue in
ganache-core
that can make thenpm install
step fail.If you see
npm ERR! code ENOLOCAL
, try runningnpm ci
instead ofnpm install
.
Open http://localhost:3000/ to see your Dapp. You will
need to have Metamask installed and listening to
localhost 8545
. You need to change your Chain ID for localhost:8545 to 31337.
You can find detailed instructions on using Hardhat and many tips in here.
- Setting up the environment
- Testing with Hardhat, Mocha and Waffle
- Setting up Metamask
- Hardhat's full documentation
For a complete introduction to Hardhat, refer to this guide.
Your environment will have everything you need to build a Dapp powered by Hardhat and React. Background on setting up Travis CI and Coveralls can be found here.
- Hardhat: An Ethereum development task runner and testing network.
- Mocha: A JavaScript test runner.
- Chai: A JavaScript assertion library.
- ethers.js: A JavaScript library for interacting with Ethereum.
- OpenZeppelin: A library for secure smart contract development.
- Waffle: To have Ethereum-specific Chai assertions/mathers.
- solidity-coverage: Solidity coverage report.
- Travis CI: Continuous integration service free for open source projects.
- Coveralls: Web service to track coverage over time.
- hardhat-gas-reporter: eth-gas-reporter plugin to estimate function and deployment gas costs.
- A sample frontend/Dapp: A Dapp which uses Create React App.
Invalid nonce
errors: if you are seeing this error on thenpx hardhat node
console, try resetting your Metamask account. This will reset the account's transaction history and also the nonce. Open Metamask, click on your account followed bySettings > Advanced > Reset Account
.