Skip to main content
This tutorial will guide you through setting up Hardhat for Sei EVM development and using OpenZeppelin contracts to build secure, standardized smart contracts. We’ll cover environment setup, contract creation, deployment, and show how to leverage OpenZeppelin’s pre-built components.
Watch the video walkthrough for this topic in the Video Tutorials section.
Deploy to Testnet FirstIt is highly recommended that you deploy to testnet (atlantic-2) first and verify everything works as expected before committing to mainnet. Doing so helps you catch bugs early, avoid unnecessary gas costs, and keep your users safe.

Try it before you install

Setting up the full toolchain takes a few minutes. If you just want to see a contract deploy to Sei, you can do both of these right now in the browser. First, confirm the RPC endpoints you’ll put in hardhat.config respond: Then add Sei testnet to your wallet and deploy a minimal Counter.sol from Remix — no Node, no install. In Remix: compile under Solidity Compiler, then Deploy & Run with Environment set to Injected Provider — MetaMask.

Table of Contents

Prerequisites

Before we begin, ensure you have the following installed:
  • Node.js (v18.0.0 or later)
  • npm (v7.0.0 or later) or yarn
  • A code editor (VS Code recommended)

Setting Up Your Development Environment

Let’s create a new project and set up Hardhat:
When prompted, choose Hardhat 3 and a TypeScript project using Mocha and Ethers.js, then follow the prompts. This generates an ESM project ("type": "module" in package.json) with @nomicfoundation/hardhat-toolbox-mocha-ethers, ethers, Hardhat Ignition, TypeScript, and a ready-to-use tsconfig.json. Then add the OpenZeppelin contract library:
Prefer a non-interactive setup (CI or scripted environments)? Do the same thing by hand — no prompts:
The @nomicfoundation/hardhat-toolbox-mocha-ethers bundle pulls in ethers, Ignition, Mocha/Chai, and the keystore, network-helpers, verify, and typechain plugins — so this single install covers everything in this guide. If you hit peer-dependency errors, re-run with --legacy-peer-deps.

Configuring Hardhat for Sei EVM

Next, we’ll need to configure Hardhat to work with the Sei EVM. Update your hardhat.config.ts file:
hardhat.config.ts
Hardhat 3 is ESM-first and requires "type": "module" in package.json (the scaffold sets this for you). Each network needs an explicit type: 'http', and plugins load via the plugins array rather than the Hardhat 2 side-effect import '@nomicfoundation/hardhat-toolbox'. A local simulated network is provided automatically — no hardhat/localhost entry required.
Hardhat 3 reads secrets through configVariable(...), backed by an encrypted keystore — so your key is never stored in a plaintext file. Set it once:
You’ll be prompted to paste the private key of the account you deploy from; Hardhat stores it encrypted on your machine. For CI, export a SEI_PRIVATE_KEY environment variable instead — configVariable falls back to it.
Use a dedicated, throwaway deploy key funded with only what you need — never a personal wallet holding real funds.

Using OpenZeppelin Contracts

OpenZeppelin provides a library of secure, tested smart contract components that you can use to build your applications. The @openzeppelin/contracts package was already installed during setup, so you’re ready to import its contracts directly.

Creating and Deploying an ERC20 Token, ERC721 NFT or an Upgradeable UUPS Token

Let’s create a simple ERC20 token using OpenZeppelin contracts. Create a new file in the contracts directory called SeiToken.sol:
contracts/SeiToken.sol
Now, create a deployment script in the ignition/modules directory called deploy-sei-token.ts:
ignition/modules/deploy-sei-token.ts
To deploy the token to the Sei testnet:

Testing Your Smart Contracts

Hardhat makes it easy to test your contracts before deploying them. Create a test file test/sei-token-test.ts:
test/sei-token-test.ts
Run your tests with:

Deploying to Sei Testnet and Mainnet

Once you’ve tested your contracts, you can deploy them to the Sei testnet or mainnet. To deploy, you’ll need:
  1. SEI tokens in your wallet for gas
  2. Your private key stored in the encrypted keystore (npx hardhat keystore set SEI_PRIVATE_KEY) — or exported as a SEI_PRIVATE_KEY environment variable in CI
Deploy to the testnet:
Deploy to the mainnet (only when you’re ready for production):