LinuxCommandLibrary

hardhat

TLDR

Create new project

$ npx hardhat init
copy
Compile contracts
$ npx hardhat compile
copy
Run tests
$ npx hardhat test
copy
Start local node
$ npx hardhat node
copy
Run deployment script
$ npx hardhat run [scripts/deploy.js]
copy
Deploy to network
$ npx hardhat run [scripts/deploy.js] --network [sepolia]
copy
Open console
$ npx hardhat console
copy

SYNOPSIS

npx hardhat [task] [options]

DESCRIPTION

Hardhat is an Ethereum development environment. It provides a local blockchain, debugging tools, and a plugin ecosystem for compiling, testing, and deploying smart contracts.
Hardhat features console.log for Solidity debugging, network forking, and TypeScript support. It's the most popular choice for professional Ethereum development.

PARAMETERS

compile

Compile Solidity contracts.
test
Run test suite.
node
Start local Ethereum node.
run script
Run JavaScript script.
console
Open interactive console.
clean
Clear cache and artifacts.
--network name
Target network.
--show-stack-traces
Show full stack traces.

CONFIGURATION

$ // hardhat.config.js
module.exports = {
  solidity: "0.8.19",
  networks: {
    sepolia: {
      url: process.env.RPC_URL,
      accounts: [process.env.PRIVATE_KEY]
    }
  }
};
copy

CAVEATS

Requires Node.js. Network configuration needs RPC URLs. Private keys should use environment variables. Gas estimation may differ from mainnet.

HISTORY

Hardhat was created by Nomic Foundation (formerly Nomic Labs) as a successor to Buidler. It became the leading Ethereum development framework, known for its developer experience and debugging capabilities.

SEE ALSO

truffle(1), foundry(1), ganache(1)

Copied to clipboard