# Hardhat: Deploying a Smart Contract
Learn how to deploy a simple Solidity-based smart contract to Evmos using the Hardhat environment
Hardhat (opens new window) is a flexible development environment for building Ethereum-based smart contracts. It is designed with integrations and extensibility in mind
# Install Dependencies
Before proceeding, you need to install Node.js (we'll use v16.x) and the npm package manager. You can download directly from Node.js (opens new window) or in your terminal:
You can verify that everything is installed correctly by querying the version for each package:
# Create Hardhat Project
To create a new project, navigate to your project directory and run:
Following the prompts should create a new project structure in your directory.
Consult the Hardhat config page (opens new window) for a list of configuration options
to specify in hardhat.config.js
.
Most importantly, you should set the defaultNetwork
entry to point to your desired JSON-RPC network:
- To get the value for privateKey:
- MetaMask -> Account Details -> Export Private Key -> add '0x' as prefix ->
privateKey1
- MetaMask -> Account Details -> Export Private Key -> add '0x' as prefix ->
To ensure you are targeting the correct network, you can query for a list of accounts available to you from your default network provider:
- To make
accounts
command work in recent hardhat (npx hardhat --version // 2.12.5
) add this tohardhat.config.js
# Deploying a Smart Contract
You will see that a default smart contract, written in Solidity,
has already been provided under contracts/Greeter.sol
:
This contract allows you to set and query a string greeting
.
Hardhat also provides a script to deploy smart contracts to a target network;
this can be invoked via the following command, targeting your default network:
Hardhat also lets you manually specify a target network via the --network <your-network>
flag:
Finally, try running a Hardhat test: