Skip to main content
This tutorial shows how to set up Hardhat for Sei EVM development. It covers environment setup, contract creation, and deployment. You use OpenZeppelin’s pre-built components to build secure, standardized smart contracts.
Watch the video walkthrough for this topic in the Video Tutorials section.
Deploy to Sei Testnet firstWe highly recommend that you deploy to Sei Testnet first. Make sure that everything works as expected before you deploy to Sei Mainnet. This helps you catch bugs early, avoid unnecessary gas costs, and keep your users safe.

Try it before you install

The full toolchain takes a few minutes to set up. If you only want to see a contract deploy to Sei, you can do both of these steps in the browser now. First, confirm that the RPC endpoints you will use in hardhat.config respond: Then add Sei Testnet to your wallet and deploy a minimal Counter.sol from Remix. You do not need Node.js or a local install. In Remix, compile the contract under Solidity Compiler. Then deploy it under Deploy & Run, with Environment set to Injected Provider - MetaMask.

Table of contents

Prerequisites

Before you start, make sure that you have installed these tools:
  • 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

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:
For a non-interactive setup (CI or scripted environments), do the same steps manually, without prompts:
The @nomicfoundation/hardhat-toolbox-mocha-ethers bundle includes ethers, Ignition, Mocha and Chai, and the keystore, network-helpers, verify, and typechain plugins. This single install covers everything in this guide. If you get peer-dependency errors, run the install again with --legacy-peer-deps.

Configuring Hardhat for Sei EVM

Next, 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'. Plugins load through the plugins array, not through the Hardhat 2 side-effect import '@nomicfoundation/hardhat-toolbox'. A local simulated network is available automatically, so you do not need a hardhat or localhost entry.
Hardhat 3 reads secrets through configVariable(...), which reads from an encrypted keystore. Hardhat never stores your key in a plaintext file. Set the key once:
Hardhat prompts you to paste the private key of the account that you deploy from. It stores the key encrypted on your machine. For CI, export a SEI_PRIVATE_KEY environment variable instead. configVariable falls back to this variable.
Use a dedicated, throwaway deploy key that holds only the funds you need. Never use a personal wallet that holds real funds.

Using OpenZeppelin contracts

OpenZeppelin has a library of secure, tested smart contract components that you can use to build your dApps. You installed the @openzeppelin/contracts package during setup, so you can import its contracts directly.

Creating and deploying an ERC20 token, ERC721 NFT or an upgradeable UUPS token

To create a simple ERC20 token with OpenZeppelin contracts, add a new file named SeiToken.sol to the contracts directory:
contracts/SeiToken.sol
Next, create a deployment script named deploy-sei-token.ts in the ignition/modules directory:
ignition/modules/deploy-sei-token.ts
To deploy the token to Sei Testnet, run this command:

Testing your smart contracts

Hardhat lets you test your contracts before you deploy them. Create a test file named test/sei-token-test.ts:
test/sei-token-test.ts
Run your tests:

Deploying to Sei Testnet and Mainnet

After you test your contracts, you can deploy them to Sei Testnet or Sei Mainnet. To deploy, you 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 Sei Testnet:
Deploy to Sei Mainnet only when you are ready for production: