Watch the video walkthrough for this topic in the Video Tutorials section.
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 inhardhat.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
- 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 you start, make sure that you have installed these tools:Setting up your development environment
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, 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'. 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.configVariable(...), which reads from an encrypted keystore. Hardhat never stores your key in a plaintext file. Set the key once:
SEI_PRIVATE_KEY environment variable instead. configVariable falls back to this variable.
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
- ERC20
- ERC721
- Upgradeable UUPS Token
To create a simple ERC20 token with OpenZeppelin contracts, add a new file named Next, create a deployment script named To deploy the token to Sei Testnet, run this command:
SeiToken.sol to the contracts directory:contracts/SeiToken.sol
deploy-sei-token.ts in the ignition/modules directory:ignition/modules/deploy-sei-token.ts
Testing your smart contracts
Hardhat lets you test your contracts before you deploy them. Create a test file namedtest/sei-token-test.ts:
test/sei-token-test.ts
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:- 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