From edd8e9d9b3f5a693ed447bfa25da482d29b02c08 Mon Sep 17 00:00:00 2001 From: alexander-sei Date: Mon, 1 Dec 2025 15:57:53 +0100 Subject: [PATCH 1/3] Add migration from other EVMs to sei --- content/evm/_meta.js | 1 + content/evm/migrate-from-other-evms.mdx | 131 ++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 content/evm/migrate-from-other-evms.mdx diff --git a/content/evm/_meta.js b/content/evm/_meta.js index 08aa6a41..5fe640ec 100644 --- a/content/evm/_meta.js +++ b/content/evm/_meta.js @@ -8,6 +8,7 @@ export default { }, networks: 'Network Information', 'differences-with-ethereum': 'Divergence from Ethereum', + 'migrate-from-other-evms': 'Migrate from Other EVMs', '-- seid CLI': { type: 'separator', diff --git a/content/evm/migrate-from-other-evms.mdx b/content/evm/migrate-from-other-evms.mdx new file mode 100644 index 00000000..6c8e5bb7 --- /dev/null +++ b/content/evm/migrate-from-other-evms.mdx @@ -0,0 +1,131 @@ +--- +title: 'Migrate Your EVM dApp to Sei' +description: 'Step-by-step checklist for teams that already run on another EVM chain and want to redeploy on Sei, including environment prep, contract migration, liquidity planning, and a QuickSwap-style example.' +keywords: + - Sei EVM migration + - cross-chain deployment + - EVM compatibility + - Sei guide + - smart contract rollout +--- + +import { Callout } from 'nextra/components'; + +# How to migrate to Sei from another EVM chain + +Sei offers full EVM bytecode compatibility plus near-instant finality and sub-second blocks. This guide distills what product teams need to do when they already run on Polygon, Base, Ethereum or another EVM chain and want to bring your dApp stack to Sei. + +## 1. Evaluate compatibility deltas + +Revisit the [Divergence from Ethereum](./differences-with-ethereum) doc and confirm every assumption your contracts/frontends make still holds. + +| Dimension | Sei EVM | Practical effect | +| ---------- | -------------------------- | --------------------------------------------------------------------------- | +| Block time | 400 ms | Faster TX inclusion → smaller `deadline` buffers and quicker price oracles. | +| Finality | Instant | No separate “safe/latest” commitment levels to poll. | +| Gas limit | 10M gas + 21 MB byte limit | Batch contract deployments by 10M gas blocks. | +| Base fee | Dynamic but never burned | Validators receive 100% of fees. | +| Execution | Parallelized EVM | No changes to your solidity code are necessary. | + +Document any feature that relies on pending state, blob opcodes, or `PREVRANDAO` entropy and plan alternatives before touching code. + +## 2. Prepare your local and CI environments + +1. **Add Sei RPC endpoints** – mainnet chain ID `1329` (`https://evm-rpc.sei-apis.com`) and testnet chain ID `1328` (`https://evm-rpc-testnet.sei-apis.com`). Use [`ChainInformation`](./networks) for the latest values. +2. **Extend toolchains** – add Sei entries to Hardhat, Foundry, Tenderly, Sourcify, etc. Example Hardhat snippet: + +```ts +// hardhat.config.ts +import '@nomicfoundation/hardhat-verify'; + +const config = { + networks: { + seiMainnet: { + url: process.env.SEI_MAINNET_RPC ?? 'https://evm-rpc.sei-apis.com', + chainId: 1329, + accounts: process.env.DEPLOYER_KEYS?.split(',') ?? [] + }, + seiTestnet: { + url: process.env.SEI_TESTNET_RPC ?? 'https://evm-rpc-testnet.sei-apis.com', + chainId: 1328, + accounts: process.env.DEPLOYER_KEYS?.split(',') ?? [] + } + } +}; + +export default config; +``` + +3. **Mirror Foundry profiles** – the [Foundry guide](./evm-foundry) shows how to run `forge script`/`forge create` against `SEI_TESTNET_RPC`/`SEI_MAINNET_RPC`. Bake those URLs plus the dummy Seitrace API key (`forge verify-contract --verifier blockscout --etherscan-api-key dummy --chain-id 1328`) into your CI templates so scripts and verifications stay deterministic. +4. **Wallets & relayers** – pre-configure MetaMask/Safe with Sei chain params or use [`addOrSwitchSeiNetwork`](../../src/components/ChainInformation/config.ts) logic in your UI. Teams using Safe transaction relays should include `chainId: 1329` payloads in their service manifests. +5. **Indexer coverage** – confirm your data stack (SeiScan, SeiTrace, self-hosted Erigon, or firehoses) exposes Sei endpoints before launch day. When running your own node, configure it with the matching release tag noted above. + +## 3. Bootstrap common infrastructure + +Most teams re-use canonical helper contracts instead of redeploying them. Sei already exposes the addresses below (pulled from `src/components/EcosystemContracts/Ecosystem-Contracts.csv`); reference them instead of redeploying: + +| Component | Address | Notes | +| ----------------------- | -------------------------------------------- | ----------------------------------------------------------- | +| Permit2 | `0xB952578f3520EE8Ea45b7914994dcf4702cEe578` | Shared allowance manager used by many DEX and wallet flows. | +| Multicall3 | `0xcA11bde05977b3631167028862bE2a173976CA11` | Enables batching and view aggregation in SDKs. | +| ImmutableCreate2Factory | `0x0000000000FFe8B47B3e2130213B802212439497` | Deterministic deployments with `CREATE2`. | +| SingletonFactory | `0xce0042B868300000d44A59004Da54A005ffdcf9f` | + +When you depend on other third-party contracts (e.g., LayerZero, Stargate, Safe), consult the full [Ecosystem Contracts page](./ecosystem-contracts) to keep addresses in sync. + +## 4. Port contracts and configuration + +1. **Parameterize chain-specific constants** – block delays, base-fee safeguards, sequencer grace periods, and `CHAIN_ID` checks should all branch on Sei IDs. +2. **Adjust gas & byte-size assumptions** – keep `gasLimit` buffers modest, but ensure calldata stays < 21 MB. +3. **SELFDESTRUCT & blob opcodes** – refactor destructive flows to "soft close" contracts and remove any blob transaction assumptions (Sei runs without blobs). +4. **Testing** – run Foundry/Hardhat suites against Sei RPC plus local anvil forks fed by Sei EVM state. Follow the [Hardhat tutorial](./evm-hardhat) to reuse its Ignition modules for ERC20/721 smoke tests. + +## 5. Plan bridging & omnichain connectivity + +- **LayerZero V2** – reuse the [`EndpointId.SEI_V2_MAINNET (30280)` config](./bridging/layerzero) so you only maintain one `layerzero.config.ts`. Generate DVN/ULN wiring with `generateConnectionsConfig` and keep enforced gas options symmetrical between Sei and the source chain. +- **Utility tasks** – port the Hardhat tasks from the LayerZero guide (`lz:deploy`, `lz:oapp:wire`, `mint`) so QA can mint/move OFTs without touching Solidity. +- **Circle CCTP / other bridges** – if you rely on canonical assets (USDC, ETH), confirm the provider has a Sei endpoint or plan to mint IBC/TokenFactory representations. +- **Pointer contracts** – when bridging non-EVM assets, register pointer contracts as described in [Pointer Contracts](../../learn/pointers) so wallets on both sides can read the same supply. + +## 6. Handle assets and liquidity + +1. **Bridge canonical assets** – follow the [Bridging guide](./bridging) to move core tokens. +2. **Oracle & price feeds** – choose oracles already live on Sei (Built-in Oracle, Pyth, Chainlink). + +## 7. Launch checklist + +- ✅ Re-deploy contracts on atlantic-2 (testnet) first, run full integration tests, and verify the contract via Hardhat plugins. +- ✅ Deploy the contracts to pacific-1 (mainnet), rerun smoke tests, and re-verify the contracts before announcing. +- ✅ Create documentation for migrating LPs/users, including faucet instructions and explorer links. + +Fees on Sei are not burned. If your protocol redistributes "burn rebates" to users, redesign that logic so it does not expect a base-fee burn component. + +## 8. Operational readiness & monitoring + +- **Automated verification** – drive everything through the [Seitrace verification APIs](./evm-verify-contracts) (`https://seitrace.com/pacific-1/api`) from CI to guarantee parity with public explorers. +- **RPC + indexer health** – for mission-critical paths, pair a community RPC (e.g., `https://evm-rpc.sei-apis.com`) with a self-hosted node built from the matching `sei-chain` release or consider adding +- **Gas parameter drift** – periodically run the `seid q params subspace evm KeyTargetGasUsedPerBlock` commands listed in [Divergence from Ethereum](./differences-with-ethereum) so dashboards stay aligned with on-chain fee policy. +- **Alerting** – subscribe to SeiTrace websockets for block/tx feeds and monitor Cosmos events (staking, slashing) that can indirectly touch EVM state. + +## Example: QuickSwap-style deployment on Sei + +Let’s mirror a Uniswap v3/QuickSwap experience: + +1. **Routers & factories** – Deploy your own `SwapRouter`, `Factory`, and NFT position managers, or fork the already-live DragonSwap stack: + - Router: `0xdD489C75be1039ec7d843A6aC2Fd658350B067Cf` + - V3 Factory: `0x75FC67473A91335B5b8F8821277262a13B38c9b3` + - Position Manager: `0x8B3c541c30f9b29560f56B9E44b59718916B69EF` +2. **Permit and multicall support** – Point your frontend SDK to the shared `Permit2` and `Multicall3` addresses from the table above so wallet flows stay identical to Polygon/Base. +3. **Liquidity migration script** – build a helper that withdraws LP on Polygon/Base, bridges underlying tokens to Sei (via IBC or CCTP), then mints new Sei LP positions. Include gas estimations tuned for Sei’s `10M` block cap. +4. **Price oracles** – reuse TWAP/Chainlink logic but shorten observation windows because Sei blocks arrive ~30× faster; this keeps time-weighted math comparable. +5. **Verification & registry** – pipe your Ignition/Foundry deployments straight into Seitrace verification (see [evm-verify-contracts](./evm-verify-contracts)) and submit metadata to the [Ecosystem Contracts registry](./ecosystem-contracts) (CSV PR + sheet entry) so integrators discover your addresses quickly. +6. **Bridge liquidity** – pair your LP onboarding campaign with the [LayerZero task flow](./bridging/layerzero#step-6-wire-the-contracts) so partner chains can send assets into Sei as soon as pools go live. + +Following this pattern is similar for a Base-native Uniswap fork: replace DragonSwap addresses with your newly deployed Sei contracts, double-check `CREATE2` salts against the ImmutableCreate2Factory, and ship. + +## Helpful references + +- [Divergence from Ethereum](./differences-with-ethereum) – opcode, gas, and state nuances. +- [EVM Networks](./networks) – RPCs, explorers, and MetaMask payloads. +- [Precompiles](./precompiles/example-usage) – interoperability patterns. +- [Ecosystem Contracts](./ecosystem-contracts) – canonical addresses (backed by `src/components/EcosystemContracts/Ecosystem-Contracts.csv`). From 7f3f0942dcac141cfd05c678668295e47a0965ab Mon Sep 17 00:00:00 2001 From: alexander-sei Date: Tue, 2 Dec 2025 18:33:02 +0100 Subject: [PATCH 2/3] Add more comparisions --- content/evm/migrate-from-other-evms.mdx | 655 +++++++++++++++++++++--- 1 file changed, 589 insertions(+), 66 deletions(-) diff --git a/content/evm/migrate-from-other-evms.mdx b/content/evm/migrate-from-other-evms.mdx index 6c8e5bb7..3b738467 100644 --- a/content/evm/migrate-from-other-evms.mdx +++ b/content/evm/migrate-from-other-evms.mdx @@ -1,41 +1,389 @@ --- title: 'Migrate Your EVM dApp to Sei' -description: 'Step-by-step checklist for teams that already run on another EVM chain and want to redeploy on Sei, including environment prep, contract migration, liquidity planning, and a QuickSwap-style example.' +description: 'Step-by-step checklist for teams that already run on another EVM chain and want to redeploy on Sei, including environment prep, contract migration, liquidity planning, and chain-specific guidance for Ethereum, Arbitrum, Base, Polygon, and Avalanche.' keywords: - Sei EVM migration - cross-chain deployment - EVM compatibility - Sei guide - smart contract rollout + - Arbitrum to Sei + - Base to Sei + - Polygon to Sei + - Avalanche to Sei + - Ethereum to Sei --- -import { Callout } from 'nextra/components'; +import { Callout, Tabs } from 'nextra/components'; # How to migrate to Sei from another EVM chain -Sei offers full EVM bytecode compatibility plus near-instant finality and sub-second blocks. This guide distills what product teams need to do when they already run on Polygon, Base, Ethereum or another EVM chain and want to bring your dApp stack to Sei. +Sei offers full EVM bytecode compatibility plus near-instant finality and sub-second blocks. This guide distills what product teams need to do when they already run on Polygon, Base, Ethereum, Arbitrum, Avalanche or another EVM chain and want to bring your dApp stack to Sei. + + +**Why Migrate to Sei?** + +- **400ms block times** – 30× faster than Ethereum, 2-5× faster than most L2s +- **~100 MGas/s throughput** – 33× higher than Ethereum mainnet +- **Instant finality** – No waiting for confirmations or safe/finalized states +- **Parallelized execution** – Higher throughput without code changes +- **Full EVM compatibility** – Deploy your existing Solidity contracts unchanged + + + +## Chain Comparison Overview + +Before diving into migration steps, understand how Sei compares to your source chain: + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureSeiEthereumArbitrumBasePolygon PoSAvalanche C-Chain
Chain ID1329142161845313743114
Block Time400 ms~12 s~250 ms~2 s~2 s~2 s
FinalityInstant~15 min (finalized)~7 days (L1 settlement)~7 days (L1 settlement)~2 min (256 blocks)~1 s
Gas Limit10M~36M32M~30M~30M15M
Native TokenSEIETHETHETHPOL (MATIC)AVAX
Parallel ExecutionYesNoNoNoNoNo
Base Fee BurnNo (100% to validators)Yes (EIP-1559)YesYesYesYes
EVM VersionPectra (w/o blobs)PectraCancunCancunShanghaiDurango
+
+ +## Chain-Specific Migration Guides + +Select your source chain to see specific migration considerations: + + + + +### Migrating from Ethereum Mainnet + +**Key Differences:** + +| Aspect | Ethereum | Sei | Migration Impact | +| ------------- | --------------------- | ---------------- | --------------------------------------------- | +| Block time | ~12 seconds | 400 ms | Reduce `deadline` buffers in DEX swaps by 30× | +| Finality | ~15 min for finalized | Instant | Remove confirmation polling logic | +| Gas limit | ~36M per block | 10M per block | Split large batch deployments | +| Fee model | EIP-1559 with burn | Dynamic, no burn | Update fee estimation UIs | +| Pending state | Yes | No | Remove pending transaction logic | + +**What to Update:** + +1. **Time-based logic:** If your contracts use block timestamps for deadlines, reduce timeouts proportionally. A 30-minute deadline on Ethereum (~150 blocks) should be ~45 seconds on Sei (~112 blocks). + +2. **Confirmation requirements:** Remove any logic that waits for multiple confirmations or checks "safe" vs "finalized" states—Sei has instant finality. + +3. **Gas estimation:** Sei's parallelized execution can slightly vary gas estimates. Add a modest buffer (10-15%) to your `gasLimit` calculations. + +4. **Fee UI:** Simplify your frontend—you can use a single `gasPrice` input instead of `maxFeePerGas` / `maxPriorityFeePerGas`. -## 1. Evaluate compatibility deltas +```ts +// Before (Ethereum EIP-1559) +const tx = await contract.method({ + maxFeePerGas: ethers.parseUnits('50', 'gwei'), + maxPriorityFeePerGas: ethers.parseUnits('2', 'gwei') +}); + +// After (Sei - simplified) +const tx = await contract.method({ + gasPrice: ethers.parseUnits('0.1', 'gwei') // Sei has much lower fees +}); +``` -Revisit the [Divergence from Ethereum](./differences-with-ethereum) doc and confirm every assumption your contracts/frontends make still holds. +5. **PREVRANDAO/DIFFICULTY:** If you use these for any randomness, integrate a VRF oracle instead—Sei's values are derived from block time, not true randomness. + + + + +### Migrating from Arbitrum + +**Key Differences:** + +| Aspect | Arbitrum | Sei | Migration Impact | +| ------------ | ------------------------- | ------------------------ | --------------------------------------- | +| Architecture | Optimistic Rollup (L2) | L1 | No L1 data availability concerns | +| Finality | ~7 days for L1 settlement | Instant | Simplify withdrawal flows | +| Sequencer | Centralized sequencer | Decentralized validators | No sequencer downtime risk | +| Block time | ~250 ms | 400 ms | Slightly slower, but with true finality | +| L1 gas | Pays L1 data costs | No L1 dependency | Simpler fee structure | + +**What to Update:** + +1. **Remove L1 interactions:** Any logic that posts data to or reads from Ethereum L1 should be removed or replaced with Sei-native alternatives. + +2. **Sequencer assumptions:** Remove any sequencer uptime checks or fallback logic—Sei uses decentralized consensus. + +3. **Withdrawal delays:** If your protocol has 7-day withdrawal windows for "L1 finality," you can remove these—Sei settles instantly. + +4. **ArbOS precompiles:** Replace any Arbitrum-specific precompiles: + +```solidity +// Arbitrum-specific (remove) +// import { ArbSys } from "@arbitrum/nitro-contracts/src/precompiles/ArbSys.sol"; +// uint256 blockNum = ArbSys(0x64).arbBlockNumber(); + +// Sei equivalent +uint256 blockNum = block.number; // Standard EVM +``` + +5. **Cross-chain messaging:** Replace Arbitrum's native bridge with [LayerZero V2](./bridging/layerzero) for omnichain connectivity. + + + -| Dimension | Sei EVM | Practical effect | -| ---------- | -------------------------- | --------------------------------------------------------------------------- | -| Block time | 400 ms | Faster TX inclusion → smaller `deadline` buffers and quicker price oracles. | -| Finality | Instant | No separate “safe/latest” commitment levels to poll. | -| Gas limit | 10M gas + 21 MB byte limit | Batch contract deployments by 10M gas blocks. | -| Base fee | Dynamic but never burned | Validators receive 100% of fees. | -| Execution | Parallelized EVM | No changes to your solidity code are necessary. | +### Migrating from Base -Document any feature that relies on pending state, blob opcodes, or `PREVRANDAO` entropy and plan alternatives before touching code. +**Key Differences:** -## 2. Prepare your local and CI environments +| Aspect | Base | Sei | Migration Impact | +| -------------- | ------------------------- | ------------------------ | -------------------------------- | +| Architecture | OP Stack Rollup (L2) | L1 | No L1 data availability concerns | +| Finality | ~7 days for L1 settlement | Instant | Simplify withdrawal flows | +| Block time | ~2 seconds | 400 ms | 5× faster block production | +| Sequencer | Coinbase-operated | Decentralized validators | No single point of failure | +| EIP-4844 blobs | Supported | Not supported | Remove blob transaction logic | -1. **Add Sei RPC endpoints** – mainnet chain ID `1329` (`https://evm-rpc.sei-apis.com`) and testnet chain ID `1328` (`https://evm-rpc-testnet.sei-apis.com`). Use [`ChainInformation`](./networks) for the latest values. -2. **Extend toolchains** – add Sei entries to Hardhat, Foundry, Tenderly, Sourcify, etc. Example Hardhat snippet: +**What to Update:** + +1. **Remove blob transactions:** Sei doesn't support EIP-4844 blob transactions. If you're using them for data availability, store data differently or use Sei's native mechanisms. + +2. **OP Stack precompiles:** Remove any Optimism/Base-specific precompile calls: + +```solidity +// Base-specific (remove) +// L1Block(0x4200000000000000000000000000000000000015).number(); + +// Use standard EVM on Sei +uint256 blockNum = block.number; +``` + +3. **Fault proof assumptions:** Remove any logic that accounts for the 7-day challenge period—Sei has instant finality. + +4. **Sequencer fee logic:** Base has a separate L1 data fee component. On Sei, fees are simpler: `Gas Used × Gas Price`. + +5. **Coinbase Wallet integrations:** Update wallet connection logic to use Sei network parameters: ```ts -// hardhat.config.ts +// Update network config +const seiMainnet = { + chainId: '0x531', // 1329 in hex + chainName: 'Sei', + nativeCurrency: { name: 'Sei', symbol: 'SEI', decimals: 18 }, + rpcUrls: ['https://evm-rpc.sei-apis.com'], + blockExplorerUrls: ['https://seitrace.com'] +}; +``` + + + + +### Migrating from Polygon PoS + +**Key Differences:** + +| Aspect | Polygon PoS | Sei | Migration Impact | +| ------------ | -------------------- | ------- | --------------------------- | +| Native token | POL (MATIC) | SEI | Update all token references | +| Block time | ~2 seconds | 400 ms | 5× faster blocks | +| Finality | ~2 min (256 blocks) | Instant | Remove checkpoint waiting | +| Checkpoints | Periodic to Ethereum | None | Simpler architecture | +| Reorgs | Possible (rare) | Never | Remove reorg handling | + +**What to Update:** + +1. **Token references:** Replace all MATIC/POL references with SEI: + +```solidity +// Before (Polygon) +// IERC20(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270).transfer(...); // WMATIC + +// After (Sei) - use native SEI or wrapped version +// Check ecosystem contracts for canonical WSEI address +``` + +2. **Checkpoint logic:** Remove any logic that waits for Polygon checkpoints to Ethereum—Sei has instant finality. + +3. **Heimdall/Bor assumptions:** Remove any Polygon-specific validator or sidechain logic. + +4. **Reorg handling:** You can safely remove block reorganization handling code—Sei's consensus prevents reorgs. + +5. **Gas price oracles:** Polygon's gas prices can spike significantly. Sei's fees are more stable due to higher throughput: + +```ts +// Polygon - needed aggressive gas price management +const gasPrice = await provider.getGasPrice(); +const boostedPrice = gasPrice.mul(120).div(100); // 20% buffer + +// Sei - simpler approach works +const gasPrice = await provider.getGasPrice(); // Usually sufficient as-is +``` + +6. **Bridge integrations:** Replace Polygon Bridge with [LayerZero](./bridging/layerzero) or other Sei-supported bridges. + + + + +### Migrating from Avalanche C-Chain + +**Key Differences:** + +| Aspect | Avalanche C-Chain | Sei | Migration Impact | +| ------------ | ----------------- | ----------------- | --------------------------- | +| Native token | AVAX | SEI | Update all token references | +| Block time | ~2 seconds | 400 ms | 5× faster blocks | +| Finality | ~1 second | Instant (~400 ms) | Similar, slightly faster | +| Subnets | Supported | N/A | Remove subnet logic | +| Gas limit | 15M | 10M | May need to split large txs | + +**What to Update:** + +1. **Token references:** Replace AVAX with SEI: + +```solidity +// Before (Avalanche) +// IERC20(0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7).transfer(...); // WAVAX + +// After (Sei) +// Use native SEI or check ecosystem contracts for WSEI +``` + +2. **Subnet interactions:** If your dApp uses Avalanche Subnets, you'll need to redesign that architecture for Sei's single-chain model or use cross-chain messaging. + +3. **Avalanche-specific precompiles:** Remove C-Chain precompile calls: + +```solidity +// Avalanche-specific (remove) +// INativeMinter(0x0200000000000000000000000000000000000001).mintNativeCoin(...) + +// Use standard EVM patterns on Sei +``` + +4. **Gas limit adjustments:** Avalanche has 15M gas limit, Sei has 10M. If you have transactions near the limit, split them: + +```ts +// If deploying large contracts, batch by gas +const MAX_GAS_PER_BATCH = 9_000_000; // Leave buffer under 10M +``` + +5. **TWAP calculations:** Both chains have fast blocks, but adjust your observation windows if migrating oracle logic: + +```solidity +// Avalanche: 1 hour = ~1800 blocks +// Sei: 1 hour = ~9000 blocks +uint32 constant TWAP_PERIOD = 9000; // Adjust for Sei's block time +``` + + + + +## Step 1: Evaluate Compatibility + +Revisit the [Divergence from Ethereum](./differences-with-ethereum) doc and confirm every assumption your contracts/frontends make still holds. + +| Dimension | Sei EVM | Practical Effect | +| -------------- | -------------------------- | -------------------------------------------------------------------------- | +| Block time | 400 ms | Faster TX inclusion → smaller `deadline` buffers and quicker price oracles | +| Finality | Instant | No separate "safe/latest" commitment levels to poll | +| Gas limit | 10M gas + 21 MB byte limit | Batch contract deployments by 10M gas blocks | +| Base fee | Dynamic but never burned | Validators receive 100% of fees | +| Execution | Parallelized EVM | No changes to your Solidity code are necessary | +| Address format | Dual (0x + sei1...) | Same private key derives both addresses | + + + +**Features Requiring Attention:** + +- **Pending state:** Sei doesn't have pending state — transactions are either included or not +- **Blob opcodes:** EIP-4844 blob transactions are not supported +- **PREVRANDAO entropy:** Returns block-time-derived value, not true randomness — use VRF oracles here +- **SELFDESTRUCT:** Deprecated; refactor to "soft close" patterns + + + +## Step 2: Prepare Your Development Environment + +### Add Sei Network Configuration + +**Hardhat Configuration:** + +```ts filename="hardhat.config.ts" import '@nomicfoundation/hardhat-verify'; const config = { @@ -50,82 +398,257 @@ const config = { chainId: 1328, accounts: process.env.DEPLOYER_KEYS?.split(',') ?? [] } + }, + etherscan: { + apiKey: { + seiMainnet: 'dummy', // Seitrace doesn't require real API key + seiTestnet: 'dummy' + }, + customChains: [ + { + network: 'seiMainnet', + chainId: 1329, + urls: { + apiURL: 'https://seitrace.com/pacific-1/api', + browserURL: 'https://seitrace.com' + } + }, + { + network: 'seiTestnet', + chainId: 1328, + urls: { + apiURL: 'https://seitrace.com/atlantic-2/api', + browserURL: 'https://seitrace.com' + } + } + ] } }; export default config; ``` -3. **Mirror Foundry profiles** – the [Foundry guide](./evm-foundry) shows how to run `forge script`/`forge create` against `SEI_TESTNET_RPC`/`SEI_MAINNET_RPC`. Bake those URLs plus the dummy Seitrace API key (`forge verify-contract --verifier blockscout --etherscan-api-key dummy --chain-id 1328`) into your CI templates so scripts and verifications stay deterministic. -4. **Wallets & relayers** – pre-configure MetaMask/Safe with Sei chain params or use [`addOrSwitchSeiNetwork`](../../src/components/ChainInformation/config.ts) logic in your UI. Teams using Safe transaction relays should include `chainId: 1329` payloads in their service manifests. -5. **Indexer coverage** – confirm your data stack (SeiScan, SeiTrace, self-hosted Erigon, or firehoses) exposes Sei endpoints before launch day. When running your own node, configure it with the matching release tag noted above. +**Foundry Configuration:** + +```toml filename="foundry.toml" +[profile.default] +src = "src" +out = "out" +libs = ["lib"] + +[rpc_endpoints] +sei_mainnet = "https://evm-rpc.sei-apis.com" +sei_testnet = "https://evm-rpc-testnet.sei-apis.com" + +[etherscan] +sei_mainnet = { key = "dummy", url = "https://seitrace.com/pacific-1/api", chain = 1329 } +sei_testnet = { key = "dummy", url = "https://seitrace.com/atlantic-2/api", chain = 1328 } +``` + +See the [Hardhat tutorial](./evm-hardhat) and [Foundry guide](./evm-foundry) for complete setup instructions. + +### Wallet Configuration + +Pre-configure MetaMask or other wallets with Sei chain params: + +```ts +const seiMainnet = { + chainId: '0x531', // 1329 + chainName: 'Sei', + nativeCurrency: { name: 'Sei', symbol: 'SEI', decimals: 18 }, + rpcUrls: ['https://evm-rpc.sei-apis.com'], + blockExplorerUrls: ['https://seitrace.com'] +}; + +await window.ethereum.request({ + method: 'wallet_addEthereumChain', + params: [seiMainnet] +}); +``` + +## Step 3: Bootstrap Common Infrastructure + +Sei already exposes canonical helper contracts—reference them instead of redeploying: + +| Component | Address | Notes | +| ----------------------- | -------------------------------------------- | ------------------------------------------------- | +| Permit2 | `0xB952578f3520EE8Ea45b7914994dcf4702cEe578` | Shared allowance manager for DEX and wallet flows | +| Multicall3 | `0xcA11bde05977b3631167028862bE2a173976CA11` | Enables batching and view aggregation | +| ImmutableCreate2Factory | `0x0000000000FFe8B47B3e2130213B802212439497` | Deterministic deployments with `CREATE2` | +| SingletonFactory | `0xce0042B868300000d44A59004Da54A005ffdcf9f` | EIP-2470 singleton factory | + +For third-party contracts (LayerZero, Safe, etc.), consult the full [Ecosystem Contracts page](./ecosystem-contracts). + +## Step 4: Port Contracts and Configuration + +### Parameterize Chain-Specific Constants + +```solidity +// Example: Chain-aware deadline calculation +function getDeadline(uint256 secondsFromNow) internal view returns (uint256) { + if (block.chainid == 1329) { // Sei mainnet + // ~2.5 blocks per second on Sei + return block.timestamp + secondsFromNow; + } else if (block.chainid == 1) { // Ethereum + // ~1 block per 12 seconds on Ethereum + return block.timestamp + secondsFromNow; + } + return block.timestamp + secondsFromNow; +} +``` + +### Adjust Gas and Size Assumptions + +- Keep `gasLimit` buffers modest but ensure calldata stays under 21 MB +- Sei's 10M gas limit per block means large deployments may need batching + +### Refactor Deprecated Patterns + +```solidity +// Before: SELFDESTRUCT (deprecated) +function destroy() external onlyOwner { + selfdestruct(payable(owner)); +} + +// After: Soft close pattern +bool public closed; + +function close() external onlyOwner { + closed = true; + // Transfer remaining funds + payable(owner).transfer(address(this).balance); +} + +modifier notClosed() { + require(!closed, "Contract is closed"); + _; +} +``` + +## Step 5: Plan Bridging and Cross-Chain Connectivity + +### LayerZero V2 + +Sei's LayerZero Endpoint ID is `30280`. See the complete [LayerZero integration guide](./bridging/layerzero). + +```ts filename="layerzero.config.ts" +import { EndpointId } from '@layerzerolabs/lz-definitions'; + +const seiContract = { + eid: EndpointId.SEI_V2_MAINNET, // 30280 + contractName: 'MyOFT' +}; +``` + +### Other Bridge Options -## 3. Bootstrap common infrastructure +- **Circle CCTP:** For USDC bridging (check availability) +- **IBC:** For Cosmos ecosystem assets +- **Pointer contracts:** For bridging non-EVM assets—see [Pointer Contracts](/learn/pointers) -Most teams re-use canonical helper contracts instead of redeploying them. Sei already exposes the addresses below (pulled from `src/components/EcosystemContracts/Ecosystem-Contracts.csv`); reference them instead of redeploying: +## Step 6: Handle Assets and Oracles -| Component | Address | Notes | -| ----------------------- | -------------------------------------------- | ----------------------------------------------------------- | -| Permit2 | `0xB952578f3520EE8Ea45b7914994dcf4702cEe578` | Shared allowance manager used by many DEX and wallet flows. | -| Multicall3 | `0xcA11bde05977b3631167028862bE2a173976CA11` | Enables batching and view aggregation in SDKs. | -| ImmutableCreate2Factory | `0x0000000000FFe8B47B3e2130213B802212439497` | Deterministic deployments with `CREATE2`. | -| SingletonFactory | `0xce0042B868300000d44A59004Da54A005ffdcf9f` | +### Bridge Canonical Assets -When you depend on other third-party contracts (e.g., LayerZero, Stargate, Safe), consult the full [Ecosystem Contracts page](./ecosystem-contracts) to keep addresses in sync. +Follow the [Bridging guide](./bridging) to move core tokens to Sei. -## 4. Port contracts and configuration +### Oracle Integration -1. **Parameterize chain-specific constants** – block delays, base-fee safeguards, sequencer grace periods, and `CHAIN_ID` checks should all branch on Sei IDs. -2. **Adjust gas & byte-size assumptions** – keep `gasLimit` buffers modest, but ensure calldata stays < 21 MB. -3. **SELFDESTRUCT & blob opcodes** – refactor destructive flows to "soft close" contracts and remove any blob transaction assumptions (Sei runs without blobs). -4. **Testing** – run Foundry/Hardhat suites against Sei RPC plus local anvil forks fed by Sei EVM state. Follow the [Hardhat tutorial](./evm-hardhat) to reuse its Ignition modules for ERC20/721 smoke tests. +Sei supports multiple oracle solutions: -## 5. Plan bridging & omnichain connectivity +| Provider | Use Case | Documentation | +| ----------------- | ----------------------------------- | ----------------------------------------- | +| Sei Native Oracle | Built-in price feeds via precompile | [Oracle Precompile](./precompiles/oracle) | +| Pyth Network | High-frequency price feeds | [Pyth on Sei](./oracles/pyth) | +| Chainlink | Industry-standard data feeds | [Chainlink on Sei](./oracles/chainlink) | +| RedStone | Modular oracle with push model | [RedStone on Sei](./oracles/redstone) | +| API3 | First-party oracle data | [API3 on Sei](./oracles/api3) | -- **LayerZero V2** – reuse the [`EndpointId.SEI_V2_MAINNET (30280)` config](./bridging/layerzero) so you only maintain one `layerzero.config.ts`. Generate DVN/ULN wiring with `generateConnectionsConfig` and keep enforced gas options symmetrical between Sei and the source chain. -- **Utility tasks** – port the Hardhat tasks from the LayerZero guide (`lz:deploy`, `lz:oapp:wire`, `mint`) so QA can mint/move OFTs without touching Solidity. -- **Circle CCTP / other bridges** – if you rely on canonical assets (USDC, ETH), confirm the provider has a Sei endpoint or plan to mint IBC/TokenFactory representations. -- **Pointer contracts** – when bridging non-EVM assets, register pointer contracts as described in [Pointer Contracts](../../learn/pointers) so wallets on both sides can read the same supply. +**TWAP Adjustments:** Because Sei blocks arrive ~30× faster than Ethereum, shorten your TWAP observation windows to maintain comparable time-weighted calculations. -## 6. Handle assets and liquidity +## Step 7: Launch Checklist -1. **Bridge canonical assets** – follow the [Bridging guide](./bridging) to move core tokens. -2. **Oracle & price feeds** – choose oracles already live on Sei (Built-in Oracle, Pyth, Chainlink). +### Testnet Deployment (atlantic-2) -## 7. Launch checklist +- [ ] Deploy all contracts to testnet (chain ID: `1328`) +- [ ] Run full integration test suite +- [ ] Verify contracts via [Seitrace](./evm-verify-contracts) +- [ ] Test wallet connections and transaction flows +- [ ] Validate oracle integrations +- [ ] Test cross-chain messaging if applicable -- ✅ Re-deploy contracts on atlantic-2 (testnet) first, run full integration tests, and verify the contract via Hardhat plugins. -- ✅ Deploy the contracts to pacific-1 (mainnet), rerun smoke tests, and re-verify the contracts before announcing. -- ✅ Create documentation for migrating LPs/users, including faucet instructions and explorer links. +### Mainnet Deployment (pacific-1) -Fees on Sei are not burned. If your protocol redistributes "burn rebates" to users, redesign that logic so it does not expect a base-fee burn component. +- [ ] Deploy contracts to mainnet (chain ID: `1329`) +- [ ] Re-run smoke tests +- [ ] Verify all contracts on Seitrace +- [ ] Update frontend configurations +- [ ] Prepare user migration documentation -## 8. Operational readiness & monitoring +**Fee Redistribution Warning:** Fees on Sei are not burned. If your protocol redistributes "burn rebates" to users, redesign that logic so it does not expect a base-fee burn component. -- **Automated verification** – drive everything through the [Seitrace verification APIs](./evm-verify-contracts) (`https://seitrace.com/pacific-1/api`) from CI to guarantee parity with public explorers. -- **RPC + indexer health** – for mission-critical paths, pair a community RPC (e.g., `https://evm-rpc.sei-apis.com`) with a self-hosted node built from the matching `sei-chain` release or consider adding -- **Gas parameter drift** – periodically run the `seid q params subspace evm KeyTargetGasUsedPerBlock` commands listed in [Divergence from Ethereum](./differences-with-ethereum) so dashboards stay aligned with on-chain fee policy. -- **Alerting** – subscribe to SeiTrace websockets for block/tx feeds and monitor Cosmos events (staking, slashing) that can indirectly touch EVM state. +## Step 8: Operational Readiness -## Example: QuickSwap-style deployment on Sei +### Contract Verification -Let’s mirror a Uniswap v3/QuickSwap experience: +Automate verification through CI using the [Seitrace APIs](./evm-verify-contracts): + +```bash +# Foundry verification +forge verify-contract --watch \ + --compiler-version "0.8.22" \ + --verifier blockscout \ + --verifier-url https://seitrace.com/pacific-1/api \ + --etherscan-api-key dummy \ + --chain-id 1329 \ + \ + +``` + +### RPC and Indexer Health + +- **Primary RPC:** `https://evm-rpc.sei-apis.com` +- **Testnet RPC:** `https://evm-rpc-testnet.sei-apis.com` +- For mission-critical paths, consider self-hosted nodes or [premium RPC providers](/learn/rpc-providers) + +### Monitoring Gas Parameters + +Periodically query fee data to keep dashboards aligned: + +```ts +// Monitor current gas prices +const feeHistory = await provider.send('eth_feeHistory', ['0x5', 'latest', []]); +const gasPrice = await provider.getGasPrice(); +``` + +## Example: Uniswap V3-Style Deployment + +Here's how to mirror a Uniswap V3 experience on Sei: + +1. **Routers & Factories:** Deploy your own or fork the existing DragonSwap stack: -1. **Routers & factories** – Deploy your own `SwapRouter`, `Factory`, and NFT position managers, or fork the already-live DragonSwap stack: - Router: `0xdD489C75be1039ec7d843A6aC2Fd658350B067Cf` - V3 Factory: `0x75FC67473A91335B5b8F8821277262a13B38c9b3` - Position Manager: `0x8B3c541c30f9b29560f56B9E44b59718916B69EF` -2. **Permit and multicall support** – Point your frontend SDK to the shared `Permit2` and `Multicall3` addresses from the table above so wallet flows stay identical to Polygon/Base. -3. **Liquidity migration script** – build a helper that withdraws LP on Polygon/Base, bridges underlying tokens to Sei (via IBC or CCTP), then mints new Sei LP positions. Include gas estimations tuned for Sei’s `10M` block cap. -4. **Price oracles** – reuse TWAP/Chainlink logic but shorten observation windows because Sei blocks arrive ~30× faster; this keeps time-weighted math comparable. -5. **Verification & registry** – pipe your Ignition/Foundry deployments straight into Seitrace verification (see [evm-verify-contracts](./evm-verify-contracts)) and submit metadata to the [Ecosystem Contracts registry](./ecosystem-contracts) (CSV PR + sheet entry) so integrators discover your addresses quickly. -6. **Bridge liquidity** – pair your LP onboarding campaign with the [LayerZero task flow](./bridging/layerzero#step-6-wire-the-contracts) so partner chains can send assets into Sei as soon as pools go live. -Following this pattern is similar for a Base-native Uniswap fork: replace DragonSwap addresses with your newly deployed Sei contracts, double-check `CREATE2` salts against the ImmutableCreate2Factory, and ship. +2. **Permit and Multicall:** Point your frontend SDK to the shared `Permit2` and `Multicall3` addresses above. + +3. **Liquidity Migration Script:** Build a helper that: + + - Withdraws LP on source chain + - Bridges underlying tokens to Sei + - Mints new Sei LP positions + - Include gas estimations tuned for Sei's 10M block cap + +4. **Price Oracles:** Reuse TWAP/Chainlink logic but shorten observation windows for Sei's faster blocks. + +5. **Verification:** Submit to [Seitrace](./evm-verify-contracts) and the [Ecosystem Contracts registry](./ecosystem-contracts). -## Helpful references +## Helpful References -- [Divergence from Ethereum](./differences-with-ethereum) – opcode, gas, and state nuances. -- [EVM Networks](./networks) – RPCs, explorers, and MetaMask payloads. -- [Precompiles](./precompiles/example-usage) – interoperability patterns. -- [Ecosystem Contracts](./ecosystem-contracts) – canonical addresses (backed by `src/components/EcosystemContracts/Ecosystem-Contracts.csv`). +- [Divergence from Ethereum](./differences-with-ethereum) – Opcode, gas, and state nuances +- [EVM Networks](./networks) – RPCs, explorers, and MetaMask payloads +- [Precompiles](./precompiles/example-usage) – Interoperability patterns +- [Ecosystem Contracts](./ecosystem-contracts) – Canonical addresses +- [LayerZero Integration](./bridging/layerzero) – Cross-chain messaging +- [Contract Verification](./evm-verify-contracts) – Contract verification guide From c6da9bd5227b5b12a86094338ceefa54f4f9c033 Mon Sep 17 00:00:00 2001 From: alexander-sei Date: Tue, 2 Dec 2025 18:55:31 +0100 Subject: [PATCH 3/3] Fix links --- content/evm/migrate-from-other-evms.mdx | 14 +++++++------- content/evm/solidity-resources.mdx | 2 -- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/content/evm/migrate-from-other-evms.mdx b/content/evm/migrate-from-other-evms.mdx index 3b738467..f1e4a96a 100644 --- a/content/evm/migrate-from-other-evms.mdx +++ b/content/evm/migrate-from-other-evms.mdx @@ -556,13 +556,13 @@ Follow the [Bridging guide](./bridging) to move core tokens to Sei. Sei supports multiple oracle solutions: -| Provider | Use Case | Documentation | -| ----------------- | ----------------------------------- | ----------------------------------------- | -| Sei Native Oracle | Built-in price feeds via precompile | [Oracle Precompile](./precompiles/oracle) | -| Pyth Network | High-frequency price feeds | [Pyth on Sei](./oracles/pyth) | -| Chainlink | Industry-standard data feeds | [Chainlink on Sei](./oracles/chainlink) | -| RedStone | Modular oracle with push model | [RedStone on Sei](./oracles/redstone) | -| API3 | First-party oracle data | [API3 on Sei](./oracles/api3) | +| Provider | Use Case | Documentation | +| ----------------- | ----------------------------------- | ------------------------------------------ | +| Sei Native Oracle | Built-in price feeds via precompile | [Oracle Precompile](./precompiles/oracle) | +| Pyth Network | High-frequency price feeds | [Pyth Network](https://docs.pyth.network/) | +| Chainlink | Industry-standard data feeds | [Chainlink on Sei](./oracles/chainlink) | +| RedStone | Modular oracle with push model | [RedStone on Sei](./oracles/redstone) | +| API3 | First-party oracle data | [API3 on Sei](./oracles/api3) | **TWAP Adjustments:** Because Sei blocks arrive ~30× faster than Ethereum, shorten your TWAP observation windows to maintain comparable time-weighted calculations. diff --git a/content/evm/solidity-resources.mdx b/content/evm/solidity-resources.mdx index f55ef9f4..07795c50 100644 --- a/content/evm/solidity-resources.mdx +++ b/content/evm/solidity-resources.mdx @@ -40,8 +40,6 @@ This page suggests a minimal set of resources for getting started with building Official documentation providing an end-to-end description of smart contracts, blockchain basics, compiling, and deployment on an EVM. - **[Solidity Patterns](https://github.com/fravoll/solidity-patterns)** A repository of code templates with explanations of their usage. -- **[Cookbook.dev](https://www.cookbook.dev)** - Offers interactive example template contracts with live editing, one-click deploy, and an AI chat integration for coding help. - **[OpenZeppelin](https://www.openzeppelin.com)** Provides a library of customizable template contracts for common Ethereum token deployments (e.g., ERC20, ERC721, ERC1155, Proxy). Note that these are not gas optimized. They provide the defacto standard for smart contract templates and are used across almost all existing smart contracts. - **[Uniswap](https://github.com/Uniswap)**