Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Glossary

Migration Contract

A migration contract is a temporary smart contract deployed to facilitate the one-time movement of user funds or state from an old contract/system to a new one during an upgrade.
Chainscore © 2026
definition
BLOCKCHAIN INFRASTRUCTURE

What is a Migration Contract?

A migration contract is a specialized smart contract that facilitates the secure and trustless transfer of user assets or data from one blockchain protocol or smart contract to an upgraded version.

A migration contract is a smart contract designed to automate the process of moving digital assets—such as tokens, NFTs, or liquidity positions—from an old or deprecated protocol to a new one. This is a critical piece of infrastructure during major protocol upgrades, hard forks, or when a project migrates to a new blockchain network (e.g., from Ethereum to a Layer 2). Its primary function is to allow users to burn or lock their old assets and receive an equivalent amount of the new assets in return, all without relying on a centralized intermediary. This ensures the migration process is permissionless, transparent, and verifiable on-chain.

The technical implementation typically involves a time-locked or deadline-based mechanism. Users submit a transaction to the migration contract, which validates their holdings of the legacy asset. Upon confirmation, the contract destroys the old tokens (often by sending them to a burn address) and mints or releases the corresponding new tokens to the user's wallet address. For decentralized finance (DeFi) protocols, this can extend to migrating complex positions like liquidity provider (LP) tokens, requiring the contract to unwind old positions and restake into new pools. Key security considerations include ensuring the contract has a sufficient and verifiable supply of the new asset and protecting against replay attacks where old transactions could be maliciously reused.

Prominent real-world examples include the Uniswap migration from V2 to V3, where a dedicated contract allowed LP token holders to upgrade, and the SushiSwap migration from the original MasterChef contract to MasterChef V2. Another classic case is the Ethereum network's migration from Proof-of-Work to Proof-of-Stake via the Beacon Chain deposit contract, which functioned as a one-way bridge for validator stakes. These contracts are often accompanied by a governance vote and a defined migration period, after which the old contract may be permanently disabled, making the migration one-way and irreversible.

key-features
ARCHITECTURE

Key Features of a Migration Contract

A migration contract is a specialized smart contract that facilitates the secure and verifiable transfer of user assets and/or governance rights from one protocol or token to a new, upgraded version.

01

Token Swap Mechanism

The core function that allows users to burn their old tokens and mint new ones at a predefined exchange rate. This is typically a one-way, atomic transaction to prevent double-spending.

  • Example: A 1:1 swap from OLD to NEW token.
  • Security: The old tokens are permanently removed from circulation, often sent to a burn address.
02

Time-Locked Migration Window

A defined period during which the swap function is active. This creates urgency and ensures a clean transition.

  • Fixed Duration: A contract may be active for 30, 60, or 90 days.
  • Post-Window Handling: The contract often includes a function for the team to recover any unclaimed new tokens or handle stragglers after the window closes.
03

Ownership & Upgradeability

Migration contracts are often owned by a multi-signature wallet or a DAO to prevent unilateral control. They may be built using proxy patterns (like Transparent or UUPS) to allow for bug fixes during the migration period without disrupting user funds.

04

State & Data Migration

For complex DeFi protocols, migration isn't just about tokens. Contracts must also handle:

  • Staked positions: Migrating liquidity provider (LP) tokens or staking rewards.
  • Governance rights: Transferring voting power from the old to the new governance token.
  • User allowances: Resetting token approvals for the new contract addresses.
05

Security & Verification

Critical features to ensure trustlessness and safety:

  • Renounced Ownership: The ultimate state where control is permanently removed after migration.
  • On-Chain Verification: All swap rates and logic are immutable and publicly auditable.
  • Emergency Pause: A guarded function to halt swaps if a critical bug is discovered.
how-it-works
BLOCKCHAIN MECHANICS

How a Migration Contract Works

A technical breakdown of the smart contract mechanism that enables the transfer of assets and state from one blockchain protocol to another.

A migration contract is a specialized smart contract that facilitates the secure and verifiable transfer of digital assets—such as tokens, NFTs, or protocol state—from an old or deprecated smart contract to a new, upgraded one. This process, often called a token migration or contract upgrade, is essential when a project deploys a new token standard, moves to a different blockchain (a chain migration), or fixes critical security vulnerabilities. The contract acts as a trusted, automated bridge, locking or burning assets on the source chain and minting or releasing equivalent assets on the destination chain based on a predefined and immutable set of rules.

The core mechanism involves a lock-and-mint or burn-and-mint model. In a typical on-chain migration, users send their old tokens to the migration contract's address. The contract burns these tokens (permanently removes them from circulation) and records the sender's address and amount in its state. Simultaneously or after a verification period, it authorizes the minting of an equivalent amount of the new token to the same address. For cross-chain migrations, the process often involves locking assets in a vault on the origin chain and providing cryptographic proof (like a Merkle proof) to a relayer or oracle that triggers the minting event on the destination chain.

Key technical considerations for a secure migration include a timelock for administrative functions, a clearly defined migration window to prevent indefinite liability, and robust event logging for full transparency. Developers must also ensure the new contract has a sufficient minting allowance for the migration contract and that the migration logic is free from reentrancy or double-spend vulnerabilities. A failed migration, as seen in early ERC-20 upgrades, can lead to permanently split liquidity and community fragmentation, underscoring the need for rigorous auditing and often a multi-signature wallet to control the contract's critical parameters.

primary-use-cases
MIGRATION CONTRACT

Primary Use Cases & Examples

A migration contract is a specialized smart contract that facilitates the secure and verifiable transfer of assets or state from one blockchain protocol or smart contract to an upgraded version. These are critical for protocol upgrades, token swaps, and chain migrations.

01

Protocol Version Upgrade

The most common use case is upgrading a DeFi protocol's core logic. When a new, audited contract version is deployed, a migration contract allows users to permissionlessly move their liquidity positions, staking deposits, or collateral from the old contract to the new one. This ensures a seamless upgrade without requiring users to manually withdraw and redeposit funds, which could be risky and cause market disruption.

  • Example: Uniswap's migration from V2 to V3 used migration contracts for liquidity providers.
02

Token Standard Migration (Token Swap)

Used when a project transitions its native token to a new smart contract, often to adopt an improved standard (e.g., from an older ERC-20 to a more feature-rich version) or to fix a critical bug. The migration contract accepts the old tokens and issues an equivalent amount of new tokens to the user's wallet. This process is often time-bound and requires users to approve the contract and initiate the swap.

  • Example: The migration of the Tether (USDT) token from the Omni Layer to Ethereum ERC-20 involved a centralized swap process, conceptually similar.
03

Cross-Chain Asset Migration

Facilitates the movement of assets and sometimes application state during a blockchain network's own upgrade or fork. When a project migrates its entire ecosystem from one base layer (e.g., Ethereum) to another (e.g., a Layer 2 or a new L1), a migration contract on the origin chain can lock assets and mint corresponding representations on the destination chain via a bridge or messaging protocol.

  • Key Mechanism: Often involves a lock-and-mint or burn-and-mint bridge pattern, with the migration contract acting as the custodian or burner on the source chain.
04

Security & Trust Minimization

A well-designed migration contract is critical for security. It must:

  • Preserve user ownership: Only the token holder can initiate their migration.
  • Maintain asset parity: Ensure a 1:1 (or defined) ratio between old and new assets.
  • Be time-limited: Include a sunset period after which the old contract is deprecated.
  • Be non-custodial: Users should not need to trust a third party with their private keys.

Failure in these aspects can lead to permanent loss of funds or exploitation.

05

Real-World Example: SushiSwap Migration

A historic example of a liquidity migration. When SushiSwap launched, it used a migration contract to incentivize users to move their liquidity provider (LP) tokens from Uniswap V2 pools to identical SushiSwap pools. The contract would:

  1. Withdraw the underlying tokens (e.g., ETH/USDC) from Uniswap.
  2. Deposit them into the new SushiSwap pool.
  3. Issue the user new SushiSwap LP tokens and SUSHI governance tokens as a reward. This event demonstrated the power and potential volatility of permissionless contract migration.
06

Developer Considerations

Building a migration contract requires meticulous planning. Key technical considerations include:

  • State Merkleization: For complex state migration, proving user balances via Merkle proofs can be more gas-efficient than storing a full mapping.
  • Upgrade Patterns: Using Proxy Patterns (like Transparent or UUPS) can sometimes reduce the need for full-contract migrations.
  • Front-running Protection: Mechanisms to prevent MEV bots from exploiting the migration sequence.
  • Fallback Functions: Ensuring the old contract can be safely paused or made inert post-migration.
security-considerations
MIGRATION CONTRACT

Security Considerations & Risks

A migration contract is a smart contract that facilitates the transfer of assets or state from one blockchain protocol or contract to another, a critical process that introduces significant attack surfaces and trust assumptions.

01

Centralized Control & Admin Keys

Migration contracts often require privileged admin functions to initiate and control the migration. This creates a central point of failure and a single point of trust. Risks include:

  • Rug pulls if admin keys are malicious or compromised.
  • Denial-of-service if keys are lost, freezing user funds.
  • Governance attacks targeting the migration proposal process.

Mitigation involves using time-locks, multi-signature wallets, and eventually transferring control to a decentralized autonomous organization (DAO).

02

Reentrancy & Logic Flaws

The complex state transition logic in migration contracts is a prime target for exploits. Key vulnerabilities:

  • Reentrancy attacks where malicious contracts re-enter the migration function before state updates.
  • Incorrect exchange rate calculations between old and new tokens.
  • Edge case failures for unusual user balances or contract interactions.

These flaws can lead to the draining of the migration vault. Rigorous audits, formal verification, and using the checks-effects-interactions pattern are essential defenses.

03

Front-Running & MEV

Migration transactions are often publicly visible in the mempool, making them susceptible to Maximal Extractable Value (MEV) exploitation. Attack vectors include:

  • Sandwich attacks on the liquidity pools for the new token.
  • Transaction reordering to benefit from time-sensitive exchange rates or limited migration windows.
  • Bidding wars that drive up gas costs for legitimate users.

Solutions include using commit-reveal schemes, private transaction relays, or conducting migrations via snapshots followed by a claim process.

04

Trust in the New System

Migrating inherently requires users to trust the security and legitimacy of the destination contract or chain. Critical considerations:

  • Audit status of the new protocol's core contracts.
  • Economic security of the new chain (e.g., validator set, stake).
  • Contract upgradeability mechanisms and their governance.
  • Bridge security if migrating across chains.

A migration to a less secure system can result in a permanent loss of funds, even if the migration process itself is flawless.

05

User Error & Phishing

Migration events are high-traffic periods that attract phishing campaigns and social engineering. Common risks:

  • Fake migration websites mimicking the official front-end.
  • Malicious token approvals that drain wallets instead of migrating.
  • Confusion leading users to send funds to the wrong address.

Protocols must communicate clearly through verified channels, use immutable, on-chain instructions, and consider implementing allowlist or permit functions to reduce approval risks.

06

Example: SushiSwap Migration (2020)

The SushiSwap migration from Uniswap v2 illustrates several security dynamics:

  • Centralized Control: The initial MasterChef migration contract was controlled by a single key held by the pseudonymous founder 'Chef Nomi', who briefly withdrew development funds.
  • Community Response: Control was transferred to a multi-sig led by FTX's Sam Bankman-Fried after community backlash.
  • Successful Outcome: Despite the trust crisis, the technical migration of ~$1B in liquidity was executed without major exploits, highlighting the separation of governance risk from contract execution risk.
code-example
SMART CONTRACT IMPLEMENTATION

Code Example: Basic Migration Logic

A practical demonstration of the core functions required for a token migration, showing how to securely transfer token ownership and balances from an old contract to a new one.

A basic migration contract implements two primary functions: one for users to deposit their old tokens and another for the contract owner to withdraw the collected tokens to fund the new contract. The core logic involves a mapping to track user deposits, a function that burns or locks the old tokens upon receipt, and an administrative function to retrieve the pooled assets. This creates a one-way bridge where users send OldToken and receive a claim to an equivalent amount of NewToken on the destination chain or contract.

The deposit function must include critical security checks, such as verifying the migration is active, ensuring the user has approved the contract to spend their tokens, and validating the amount is greater than zero. A typical implementation uses the transferFrom function of the old token's interface to pull tokens into the migration contract's custody, subsequently updating an internal ledger. Emitting an event like TokensDeposited is essential for transparency, providing users with on-chain proof of their transaction.

Owner-controlled functions, like withdrawCollectedTokens, require access control modifiers (e.g., onlyOwner) to prevent unauthorized withdrawals. This function would call the old token's transfer function to send the entire accumulated balance to a specified wallet, often the deployer of the new token contract. It is considered a best practice to include a mechanism to pause migrations and to allow users to reclaim their old tokens in case of a critical issue, adding a layer of safety to the process.

For a complete solution, this on-chain logic must be paired with an off-chain component or a second contract that mints or unlocks the new tokens for users. This is often handled by a claim function on the new contract, which reads the migration contract's deposit ledger. Developers must also account for differences in decimals, supply caps, and tokenomics between the old and new assets, potentially applying conversion ratios within the migration logic itself.

UPGRADE PATTERN COMPARISON

Migration Contract vs. Other Upgrade Patterns

A technical comparison of contract upgradeability mechanisms, focusing on implementation, security, and operational trade-offs.

Feature / MetricMigration ContractProxy PatternDiamond Standard (EIP-2535)

Core Mechanism

Deploy new contract, move state & logic

Delegate calls to mutable logic contract

Modular facets delegate to a central diamond

State Migration

Manual, explicit transfer required

Persistent in proxy storage

Persistent in diamond storage

Implementation Immutability

New logic contract is immutable

Logic contract is upgradeable

Individual facets are immutable

Gas Cost for Upgrade

High (deploy + migration tx)

Low (single storage slot update)

Low to Medium (facet management)

Upgrade Complexity

High (orchestration risk)

Low (single pointer swap)

Medium (facet dependency management)

Storage Collision Risk

None (fresh storage layout)

High (must preserve layout)

Managed via dedicated slots

Monolithic vs Modular

Monolithic (full replacement)

Monolithic (single logic contract)

Modular (multiple logic facets)

Audit Surface per Upgrade

Full re-audit recommended

Incremental logic audit

Incremental facet audit

ecosystem-usage
MIGRATION CONTRACT

Ecosystem Usage: Notable Examples

Migration contracts are critical infrastructure for protocol upgrades and chain transitions. These examples highlight their diverse implementations and the scale of assets they manage.

01

Uniswap v2 to v3 Migration

The Uniswap v3 migration contract facilitated the upgrade of liquidity provider (LP) positions from the older v2 protocol to the new, more capital-efficient v3 system. Key functions included:

  • Burning old v2 LP tokens
  • Minting new v3 LP tokens with concentrated liquidity positions
  • A governance-approved process that allowed LPs to move their capital to the upgraded system, which introduced features like custom price ranges and multiple fee tiers.
$3B+
Peak Value Migrated
02

SushiSwap Migration (from Uniswap)

This high-profile example involved a vampire attack where SushiSwap's migration contract incentivized users to move liquidity from Uniswap. The contract's core mechanism was a timelock-controlled function that:

  • Allowed users to deposit Uniswap v2 LP tokens
  • Staked them to earn SUSHI governance tokens
  • After a set period, executed the masterChef function to permanently migrate the underlying liquidity to SushiSwap's own pools, demonstrating the use of migration contracts in competitive liquidity mining.
03

Polygon (Matic) Token Migration

The Polygon network executed a token migration contract to upgrade its ERC-20 token standard. The contract handled the 1:1 swap from the old MATIC (ERC-20) token to the new POL token, which is central to Polygon 2.0's vision. This involved:

  • A bridging mechanism for tokens on Ethereum mainnet
  • Support for staked positions and delegations to be carried over
  • A long-term, user-operated migration window to ensure a smooth transition for all token holders and validators.
04

dYdX's Move to a Cosmos AppChain

dYdX's migration from an Ethereum Layer 2 (StarkEx) to its own Cosmos-based application-specific blockchain required a sophisticated migration contract. This contract managed the transfer of user assets and state, including:

  • Withdrawing funds from the L2 to Ethereum mainnet
  • Bridging assets via the dYdX Chain bridge
  • Recreating user positions (balances, open orders) on the new chain, showcasing migration contracts in full-stack protocol migration beyond a simple token swap.
05

Compound Finance v2 to v3 Upgrade

Compound's upgrade to v3 introduced isolated collateral markets and more efficient capital usage. While a direct, atomic migration contract was not the primary path, the protocol used comptroller and cToken contracts with upgrade functions to facilitate the transition. Key aspects included:

  • Pausing old markets and enabling new ones
  • Price oracle migration to a new system
  • Governance proposals to set parameters for the new collateral factors and borrow caps, illustrating a phased, governance-driven migration approach.
06

Wrapped Bitcoin (WBTC) Custodian Migration

WBTC employs a multi-signature custodian model where the custodian set can be changed via a migration-like process governed by the WBTC DAO. This involves deploying a new custodian contract and using a migration function to:

  • Verify the total supply on the old contract
  • Mint an equivalent supply on the new contract
  • Transfer control of the underlying Bitcoin reserves, highlighting migration contracts in the context of upgrading institutional custody arrangements for a bridged asset.
$10B+
Asset Value Secured
MIGRATION CONTRACT

Frequently Asked Questions (FAQ)

Essential questions and answers about smart contracts that facilitate the movement of assets or data from one blockchain protocol or version to another.

A migration contract is a specialized smart contract that facilitates the secure and trustless transfer of assets, data, or governance rights from an old protocol or blockchain to a new one. It works by locking or burning assets on the source chain and minting or releasing a corresponding amount of the new asset on the destination chain. The process is typically initiated by a user sending their old tokens to the migration contract's address. The contract's logic then validates the transaction and, upon confirmation, triggers a corresponding action on the new chain, often via a bridge or a minting authority. This mechanism is crucial for protocol upgrades, token swaps, and chain migrations, ensuring a smooth transition without centralized intermediaries.

ENQUIRY

Get In Touch
today.

Our experts will offer a free quote and a 30min call to discuss your project.

NDA Protected
24h Response
Directly to Engineering Team
10+
Protocols Shipped
$20M+
TVL Overall
NDA Protected Directly to Engineering Team