# Hardhat official tutorial location: https://hardhat.org/tutorial/creating-a-new-hardhat-project.html ## Setting up the environment install node.js ## Creating a new Hardhat project Open a new terminal and run these commands: ``` mkdir hardhat-tutorial cd hardhat-tutorial npm init --yes npm install --save-dev hardhat ``` In the same directory where you installed Hardhat run: ``` npx hardhat ``` ### Hardhat's architecture Hardhat is designed around the concepts of tasks and plugins. The bulk of Hardhat's functionality comes from plugins, which as a developer you're free to choose the ones you want to use. ### Tasks Every time you're running Hardhat from the CLI you're running a task. e.g. npx hardhat compile is running the compile task. To see the currently available tasks in your project, run npx hardhat. Feel free to explore any task by running npx hardhat help [task]. ### Plugins Hardhat is unopinionated in terms of what tools you end up using, but it does come with some built-in defaults. All of which can be overriden. Most of the time the way to use a given tool is by consuming a plugin that integrates it into Hardhat. For this tutorial we are going to use the Ethers.js and Waffle plugins. They'll allow you to interact with Ethereum and to test your contracts. ``` npm install --save-dev @nomiclabs/hardhat-ethers ethers @nomiclabs/hardhat-waffle ethereum-waffle chai ``` ## Contract ### compile ``` npx hardhat compile ``` ## Testing contracts ``` npx hardhat test ``` ## Debugging with Hardhat Network Hardhat comes built-in with Hardhat Network, a local Ethereum network designed for development. It allows you to deploy your contracts, run your tests and debug your code. It's the default network Hardhat connects to, so you don't need to setup anything for it to work. Just run your tests. ### Solidity console.log ## Deploying to a live network There's the Ethereum network that deals with real money which is called "mainnet", and then there are other live networks that don't deal with real money but do mimic the real world scenario well, and can be used by others as a shared staging environment. These are called "testnets" and Ethereum has multiple ones: Ropsten, Kovan, Rinkeby and Goerli. We recommend you deploy your contracts to the Ropsten testnet. ``` npx hardhat run scripts/deploy.js npx hardhat run scripts/deploy.js --network <network-name> ``` ### Deploying to remote networks To deploy to a remote network such as mainnet or any testnet, you need to add a network entry to your hardhat.config.js file. We’ll use Ropsten for this example, but you can add any network similarly: ``` npx hardhat run scripts/deploy.js --network ropsten ``` ## Hardhat Hackathon Boilerplate Project https://github.com/nomiclabs/hardhat-hackathon-boilerplate 1. ``` cd hardhat-hackathon-boilerplate/ npm install npx hardhat node ``` 2. ``` npx hardhat --network localhost run scripts/deploy.js ``` 3. ``` cd hardhat-hackathon-boilerplate/frontend/ npm install npm run start ```