Skip to content

Create, compile, deploy and verify Smart Contracts with Hardhat

License

Notifications You must be signed in to change notification settings

orbanszlrd/hardhat-user-storage

Repository files navigation

Hardhat UserStorage Demo Project

Create, compile, deploy and verify Smart Contracts with Hardhat.

Create a Smart Contract

  • Create a new contract in the contracts folder.
  • Create a deploy script for it
  • Run the script

Compile Smart Contracts

The command below compiles every .sol file in your contracts folder.

npm run compile

You can find the compiled contracts in the artifacts folder

Deploy Smart Contracts to different Networks

To deploy a contract to a remote network you need a url and a private key.

  • For getting a url, go to Alchemy, sign up, create a new App in its dashboard

  • For the private key you need to install MetaMask, create an account and export its private key

  • To verify your smart contracts, sign up to Etherscan and create an API Key

Hardhat (Default)

Hardhat comes built-in with Hardhat Network, a local Ethereum network node designed for development

npm run deploy

Hardhat (Localhost)

npm run deploy:localhost

Ganache

Ganache is a personal blockchain running on your own mashine on port 7545.

npm run deploy:ganache

Goerli

Goerli is an Ethereum test network that allows for blockchain development testing before deployment on Mainnet, the main Ethereum network.

npm run deploy:goerli

Testing Smart Contracts

Writing automated tests when building smart contracts is of crucial importance. We can use Mocha test runner and the Chai assertion library.

Running Tests

npm run test

Running Tests with Coverage

For test coverage you need to install the solidity-coverage package.

npm run coverage

Further Help

Alchemy - The Web3 Development Platform
Ethereum - Technology powering the Cryptocurrency Ether
Ethers.js - Library for interacting with the Ethereum Blockchain
Etherscan - The Ethereum Blockchain Explorer
Hardhat - Ethereum Development Environment for Professionals
MetaMask - A Crypto Wallet & Gateway to Blockchain Apps
Solidity - Programming Language for implementing Smart Contracts
Ganache - Personal Blockchain for Ethereum development