MediumComplete Guide: Setting Up Sei Blockchain Development Environment | by Tushar S | Medium
Sitemap

Complete Guide: Setting Up Sei Blockchain Development Environment

7 min readSep 24, 2025

--

Press enter or click to view image in full size

Sei Network is a high-performance, EVM-compatible blockchain designed for decentralized exchanges and DeFi applications. With its unique Twin Turbo consensus mechanism and native order matching engine, Sei offers sub-second finality and exceptional throughput. This comprehensive guide will walk you through setting up a complete development environment for building on Sei.

What is Sei Network?

Sei is the first sector-specific Layer 1 blockchain, purpose-built for trading. It combines the best of Cosmos SDK with Ethereum Virtual Machine (EVM) compatibility, offering developers the flexibility to build in both ecosystems. Key features include:

  • Sub-second finality with Twin Turbo consensus
  • Built-in order matching engine for DEX applications
  • EVM compatibility for existing Ethereum tools
  • Native oracle price feeds for real-time market data
  • Parallelized EVM for enhanced performance

Prerequisites

Before we begin, ensure you have the following installed:

  • Node.js (v20.10.0 or higher) — Download here
  • npm or yarn package manager
  • Git for version control
  • A code editor like VS Code
  • MetaMask or similar Web3 wallet

Step 1: Project Initialization

Let’s start by creating a new project directory and initializing it:

# Create project directory
mkdir sei-dapp-project
cd sei-dapp-project
# Initialize npm project
npm init -y

Step 2: Installing Hardhat and Dependencies

Hardhat is the most popular Ethereum development framework, and it works perfectly with Sei’s EVM compatibility:

# Install Hardhat and essential tools
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
# Install OpenZeppelin contracts for secure development
npm install --save-dev @openzeppelin/contracts
# Install dotenv for environment variables
npm install --save-dev dotenv

Step 3: Handling ESM Compatibility

Modern versions of Hardhat require ESM (ES Modules) support. Update your package.json:

{
"name": "sei-dapp-project",
"version": "1.0.0",
"type": "module",
"scripts": {
"test": "npx hardhat test",
"compile": "npx hardhat compile",
"deploy:local": "npx hardhat run scripts/deploy.js --network hardhat",
"deploy:testnet": "npx hardhat run scripts/deploy.js --network seitestnet",
"deploy:mainnet": "npx hardhat run scripts/deploy.js --network seimainnet",
"node": "npx hardhat node"
},
"devDependencies": {
"@nomicfoundation/hardhat-toolbox": "^6.1.0",
"@openzeppelin/contracts": "^5.4.0",
"dotenv": "^16.4.5",
"hardhat": "^3.0.6"
}
}

Step 4: Configuring Hardhat for Sei Networks

Create a hardhat.config.cjs file (note the .cjs extension for CommonJS compatibility):

require('@nomicfoundation/hardhat-toolbox');
require('dotenv/config');
const PRIVATE_KEY = process.env.PRIVATE_KEY || 'your-private-key-placeholder';/** @type import('hardhat/config').HardhatUserConfig */
const config = {
solidity: {
version: '0.8.28',
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
networks: {
// Sei Pacific Testnet (EVM)
seitestnet: {
url: 'https://evm-rpc-testnet.sei-apis.com',
accounts: [PRIVATE_KEY],
chainId: 1328,
gasPrice: 2000000000 // 2 gwei = 2 nsei
},
// Sei Pacific Mainnet (EVM)
seimainnet: {
url: 'https://evm-rpc.sei-apis.com',
accounts: [PRIVATE_KEY],
chainId: 1329,
gasPrice: 2000000000
},
// Local development
hardhat: {
chainId: 31337
}
},
paths: {
sources: './contracts',
tests: './test',
cache: './cache',
artifacts: './artifacts'
},
mocha: {
timeout: 40000
}
};
module.exports = config;

Step 5: Environment Variables Setup

Create a .env file for sensitive information:

# .env file
PRIVATE_KEY=your_actual_private_key_here_without_0x_prefix

Security Note: Never commit your .env file to version control. Create a .gitignore file:

node_modules/
.env
cache/
artifacts/
*.log

Step 6: Creating Project Structure

Set up the standard Hardhat project structure:

mkdir -p contracts test scripts

Step 7: Writing Your First Sei Smart Contract

Create a simple contract in contracts/SeiGreeting.sol:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
contract SeiGreeting is Ownable, ReentrancyGuard {
string public greeting;
uint256 public greetingCount;

event GreetingUpdated(string newGreeting, address updatedBy, uint256 timestamp);

constructor(string memory _initialGreeting) Ownable(msg.sender) {
greeting = _initialGreeting;
greetingCount = 0;
}

function updateGreeting(string memory _newGreeting) public {
require(bytes(_newGreeting).length > 0, "Greeting cannot be empty");

greeting = _newGreeting;
greetingCount++;

emit GreetingUpdated(_newGreeting, msg.sender, block.timestamp);
}

function getGreetingInfo() public view returns (string memory, uint256, address) {
return (greeting, greetingCount, owner());
}

// Emergency function for owner
function resetGreeting() public onlyOwner {
greeting = "Hello, Sei!";
greetingCount = 0;
}
}

Step 8: Writing Tests

Create comprehensive tests in test/SeiGreeting.test.js:

import { expect } from "chai";
import { ethers } from "hardhat";
describe("SeiGreeting", function () {
let SeiGreeting, seiGreeting, owner, addr1, addr2;
beforeEach(async function () {
SeiGreeting = await ethers.getContractFactory("SeiGreeting");
[owner, addr1, addr2] = await ethers.getSigners();
seiGreeting = await SeiGreeting.deploy("Hello, Sei Network!");
await seiGreeting.waitForDeployment();
});
describe("Deployment", function () {
it("Should set the right owner", async function () {
expect(await seiGreeting.owner()).to.equal(owner.address);
});
it("Should set the initial greeting", async function () {
expect(await seiGreeting.greeting()).to.equal("Hello, Sei Network!");
});
it("Should initialize greeting count to 0", async function () {
expect(await seiGreeting.greetingCount()).to.equal(0);
});
});
describe("Greeting updates", function () {
it("Should update greeting and increment count", async function () {
const newGreeting = "Sei is amazing!";
await seiGreeting.updateGreeting(newGreeting);

expect(await seiGreeting.greeting()).to.equal(newGreeting);
expect(await seiGreeting.greetingCount()).to.equal(1);
});
it("Should emit GreetingUpdated event", async function () {
const newGreeting = "Testing events on Sei";
await expect(seiGreeting.updateGreeting(newGreeting))
.to.emit(seiGreeting, "GreetingUpdated")
.withArgs(newGreeting, owner.address, await ethers.provider.getBlock('latest').then(b => b.timestamp + 1));
});
it("Should reject empty greeting", async function () {
await expect(seiGreeting.updateGreeting(""))
.to.be.revertedWith("Greeting cannot be empty");
});
});
describe("Owner functions", function () {
it("Should allow owner to reset greeting", async function () {
await seiGreeting.updateGreeting("Changed greeting");
await seiGreeting.resetGreeting();

expect(await seiGreeting.greeting()).to.equal("Hello, Sei!");
expect(await seiGreeting.greetingCount()).to.equal(0);
});
it("Should reject non-owner reset attempts", async function () {
await expect(seiGreeting.connect(addr1).resetGreeting())
.to.be.revertedWithCustomError(seiGreeting, "OwnableUnauthorizedAccount");
});
});
});

Step 9: Deployment Scripts

Create a deployment script in scripts/deploy.js:

import hre from "hardhat";
async function main() {
const [deployer] = await hre.ethers.getSigners();

console.log("🚀 Deploying contracts with account:", deployer.address);
console.log("💰 Account balance:", hre.ethers.formatEther(await deployer.provider.getBalance(deployer.address)), "ETH");
// Deploy SeiGreeting contract
console.log("📝 Deploying SeiGreeting contract...");
const SeiGreeting = await hre.ethers.getContractFactory("SeiGreeting");
const seiGreeting = await SeiGreeting.deploy("Hello from Sei blockchain! 🌊");
await seiGreeting.waitForDeployment(); const contractAddress = await seiGreeting.getAddress();
console.log("✅ SeiGreeting deployed to:", contractAddress);

// Verify deployment by calling contract functions
console.log("🔍 Verifying deployment...");
const greeting = await seiGreeting.greeting();
const count = await seiGreeting.greetingCount();
const owner = await seiGreeting.owner();

console.log("📋 Contract Details:");
console.log(" Initial greeting:", greeting);
console.log(" Greeting count:", count.toString());
console.log(" Contract owner:", owner);

console.log("\n🎉 Deployment completed successfully!");
console.log("💡 Save this contract address for future interactions:", contractAddress);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error("❌ Deployment failed:", error);
process.exit(1);
});

Step 10: Getting Testnet Tokens

Before deploying to Sei testnet, you need SEI tokens:

  1. Get your wallet address from your private key
  2. Visit the Sei faucet: https://docs.sei.io/learn/faucet
  3. Request testnet tokens (you’ll receive test SEI)
  4. Wait for confirmation (usually takes a few seconds)

Step 11: Compilation and Testing

Now let’s test our setup:

# Compile contracts
npx hardhat compile
# Run tests
npm test
# Start local Hardhat node (in separate terminal)
npm run node
# Deploy to local network
npm run deploy:local

Step 12: Deploying to Sei Testnet

With testnet tokens in your wallet:

# Deploy to Sei testnet
npm run deploy:testnet

Expected output:

🚀 Deploying contracts with account: 0x...
💰 Account balance: 10.0 ETH
📝 Deploying SeiGreeting contract...
✅ SeiGreeting deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3
🔍 Verifying deployment...
📋 Contract Details:
Initial greeting: Hello from Sei blockchain! 🌊
Greeting count: 0
Contract owner: 0x...

Step 13: Connecting MetaMask to Sei

To interact with your deployed contracts via MetaMask:

Get Tushar S’s stories in your inbox

Join Medium for free to get updates from this writer.

Sei Testnet Configuration:

Sei Mainnet Configuration:

Advanced Features and Tips

Gas Optimization for Sei

Sei’s high throughput allows for more complex operations. Consider these optimizations:

// Batch operations to leverage Sei's performance
function batchUpdateGreetings(string[] memory _greetings) public {
for (uint i = 0; i < _greetings.length; i++) {
updateGreeting(_greetings[i]);
}
}

Leveraging Sei’s Native Features

Sei offers unique features like native oracle integration:

// Example of using Sei's built-in price feeds (conceptual)
const priceData = await seiContract.getOraclePrice("SEI/USDT");

Monitoring and Analytics

Use Sei’s block explorers and tools:

  • SeiTrace: https://seitrace.com for transaction monitoring
  • Sei Network Status: Track network health and performance
  • DeFiLlama: Monitor TVL and protocol metrics

Troubleshooting Common Issues

ESM Module Errors

If you encounter ESM-related errors, ensure:

  • "type": "module" is in package.json
  • Config file uses .cjs extension
  • Scripts use import syntax

Gas Estimation Failures

For gas issues:

// Add explicit gas settings
await contract.method({
gasLimit: 500000,
gasPrice: ethers.utils.parseUnits('2', 'gwei')
});

Network Connection Issues

Verify your network configuration and try alternative RPC endpoints if needed.

Best Practices for Sei Development

  1. Security First: Always use OpenZeppelin contracts and follow security best practices
  2. Gas Efficiency: While Sei is fast, optimize for gas to reduce costs
  3. Testing: Write comprehensive tests before mainnet deployment
  4. Monitoring: Set up monitoring for your deployed contracts
  5. Documentation: Document your smart contracts and deployment processes

Next Steps

Now that you have a complete Sei development environment:

  1. Explore DeFi Primitives: Build DEX components leveraging Sei’s trading focus
  2. Integrate Oracles: Use Sei’s native price feeds for real-time data
  3. Build Frontend: Create user interfaces with Web3 libraries
  4. Deploy to Mainnet: When ready, deploy your tested contracts to Sei mainnet
  5. Join the Community: Engage with Sei developers on Discord and GitHub

Conclusion

Setting up a Sei blockchain development environment opens doors to building high-performance DeFi applications. With its unique combination of speed, EVM compatibility, and trading-focused features, Sei provides an excellent platform for next-generation decentralized applications.

The configuration we’ve built provides a solid foundation for any Sei project, from simple smart contracts to complex DeFi protocols. Remember to always test thoroughly on testnet before mainnet deployment, and stay updated with Sei’s evolving ecosystem.

Happy building on Sei! 🌊

Resources:

About the Author

This guide was written by Tushar Sengar, a blockchain & Full Stack developer passionate about building on cutting-edge networks like Sei. If you have questions about this tutorial, need help with your Sei development journey, or want to discuss blockchain development in general, feel free to reach out!

Contact Information:

I’m always happy to help fellow developers and discuss the latest in blockchain technology. Don’t hesitate to connect!

--

--