Watch the video walkthrough for this topic in the Video Tutorials section.
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 inhardhat.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
- Try it before you install
- Prerequisites
- Setting Up Your Development Environment
- Configuring Hardhat for Sei EVM
- Using OpenZeppelin Contracts
- Creating and Deploying an ERC20 Token, ERC721 NFT or an Upgradeable UUPS Token
- Testing Your Smart Contracts
- Deploying to Sei Testnet and Mainnet
Prerequisites
Before we begin, ensure you have the following installed:Setting Up Your Development Environment
Let’s create a new project and set up Hardhat:"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:
Configuring Hardhat for Sei EVM
Next, we’ll need to configure Hardhat to work with the Sei EVM. Update yourhardhat.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.configVariable(...), backed by an encrypted keystore — so your key is never stored in a plaintext file. Set it once:
SEI_PRIVATE_KEY environment variable instead — configVariable falls back to it.
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
- ERC20
- ERC721
- Upgradeable UUPS Token
Let’s create a simple ERC20 token using OpenZeppelin contracts. Create a new file in the Now, create a deployment script in the To deploy the token to the Sei testnet:
contracts directory called SeiToken.sol:contracts/SeiToken.sol
ignition/modules directory called deploy-sei-token.ts:ignition/modules/deploy-sei-token.ts
Testing Your Smart Contracts
Hardhat makes it easy to test your contracts before deploying them. Create a test filetest/sei-token-test.ts:
test/sei-token-test.ts
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:- SEI tokens in your wallet for gas
- Your private key stored in the encrypted keystore (
npx hardhat keystore set SEI_PRIVATE_KEY) — or exported as aSEI_PRIVATE_KEYenvironment variable in CI