This repository contains a sample project that you can use as the starting point for your Ethereum project. It's also a great fit for learning the basics of smart contract development.
This project is intended to be used with the
Hardhat Beginners Tutorial, but you should be
able to follow it by yourself by reading the README and exploring its
contracts
, tests
, scripts
and frontend
directories.
The first things you need to do are cloning this repository and installing its dependencies:
git clone https://github.com/boda805/elmo.git
cd elmo
yarn install-all
Then we can compile contracts for the EVM:
yarn compile
Start the optimistic ethereum L1/L2 locally. See pinned message in Discord for now.
In order to compile contracts for optimistic ethereum, we need to install the OVM compiler. We also need to install the OVM base contracts as well as a "watcher" utility that "helps watch and waits for messages to be relayed between L1 and L2":
yarn add @eth-optimism/hardhat-ovm \
@eth-optimism/contracts \
@eth-optimism/watcher
yarn compile-ovm
Then, on a new terminal, go to the repository's root folder and run this to deploy your contract:
yarn deploy-ovm
Finally, we can run the frontend with:
yarn start-frontend
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 can find detailed instructions on using this repository and many tips in its documentation.
- Project description (Token.sol)
- 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.
- 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.
- Waffle: To have Ethereum-specific Chai assertions/mathers.
- 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
.
We'd love to have your feedback on this tutorial. Feel free to reach us through this repository or our Discord server.
Also you can follow us on Twitter.
Happy buidling!