Using Hardhat

This page describes how to deploy smart contracts using Hardhat.


Hardhat is a development environment for Ethereum software. It consists of different components for editing, compiling, debugging and deploying your smart contracts and dApps, all of which work together to create a complete development environment.

Hardhat documentation, see:


  1. Install Hardhat

> npm install --save-dev hardhat

To create a new Hardhat project,

> npx hardhat

Select Create a TypeScript project then press enter to confirm the project root.

Select y for both adding a .gitignore and loading the sample project.

  1. Update your project’s hardhat.config.ts file by adding Kroma Mainnet as a network:

import { HardhatUserConfig } from 'hardhat/config';
import '@nomicfoundation/hardhat-toolbox';


const config: HardhatUserConfig = {
  solidity: {
    version: '0.8.17',
  networks: {
    // for kroma mainnet
    'kroma-mainnet': {
      url: '',
      chainId: 255,
      accounts: [process.env.PRIVATE_KEY as string],
    // for local devnet
    'kroma-local': {
      url: 'http://localhost:8545',
      chainId: 7790,
      accounts: [process.env.PRIVATE_KEY as string],
  defaultNetwork: 'hardhat',

export default config;
  1. create a .env file with the following content ( It is critical that you do NOT commit this to a public repo)

  1. Finaly, Run it using npx hardhat run

> npx hardhat run scripts/deploy.ts --network kroma-mainnet

Last updated