← Protocols
ZKsync Era
01Description

ZKsync Era is Matter Labs' Type-4 zkEVM Layer 2 — Solidity/Vyper source compiles via the LLVM-based zksolc/zkvyper compilers to a custom bytecode (not raw EVM bytecode), with each batch proven by a SNARK and settled on Ethereum L1. Mainnet chain ID 324, gas token ETH, with native account abstraction (every account is a smart account) and protocol-level paymaster support for gasless or ERC-20-paid transactions.

02Best for
  • 01native account abstraction without ERC-4337 plumbing
  • 02consumer apps that want gasless / ERC-20 gas via paymasters
  • 03ZK L2 with ETH gas and Ethereum settlement
  • 04ZK Stack / Elastic Network rollups sharing a unified bridge
03Install
  • pnpm add viem wagmi
  • pnpm add zksync-ethers ethers
  • pnpm add -D @matterlabs/hardhat-zksync
04Environment variables
VariableScopeDescription
NEXT_PUBLIC_ZKSYNC_RPC_URLClientZKsync Era RPC URL (mainnet: https://mainnet.era.zksync.io).
NEXT_PUBLIC_ZKSYNC_CHAIN_IDClientChain ID — 324 for Era mainnet, 300 for Sepolia testnet.
05Prompt snippet
Use viem's built-in `zksync` / `zksyncSepoliaTestnet` chains — chain ID 324, gas token ETH, RPC `https://mainnet.era.zksync.io`. Do NOT deploy with stock `forge create` or stock `hardhat-ethers` — ZKsync requires the `zksolc` compiler and the `@matterlabs/hardhat-zksync` plugin (or Foundry-zksync `forge create --zksync`). Source code stays plain Solidity; the toolchain emits ZKsync-flavored bytecode and a different `CREATE2` address derivation. Account abstraction is native: every account is a smart account, so users can submit txs signed via WebAuthn/passkey/multisig and dapps can attach a paymaster (`PaymasterParams`) to sponsor gas or accept ERC-20 fees. Use `zksync-ethers` for the higher-level helpers (deposits, withdrawals, paymaster utilities) and the official Bridge UI (`portal.zksync.io`) for canonical asset movement.
06Gotchas
  • ZKsync is Type-4: Solidity source is portable but bytecode is NOT. A contract verified on Etherscan does not match the bytecode on Era — verify via `zksync-explorer` and the zksolc-emitted artifacts. Gas, opcode availability, and `CREATE2` address derivation differ from EVM mainnet.
  • Native account abstraction means every account behaves like a smart contract — `tx.origin == msg.sender` checks and assumptions like "EOAs cannot run code" are false. Reentrancy and signature-validation patterns must use ERC-1271, and `ecrecover`-only auth will lock out smart accounts (which is most users).
  • Some opcodes/precompiles behave differently or are unsupported (`SELFDESTRUCT` is disabled, `CREATE` from EOAs has caveats, certain `MODEXP` inputs differ, no `BLOBHASH`). Re-test gas-sensitive and assembly-heavy contracts; do not assume mainnet receipts hold.
  • Sequencer is centralized and operated by Matter Labs today — there is no permissionless fallback. Force-inclusion via the L1 priority queue exists but is rarely used. Plan for liveness incidents and document an exit story.
  • Withdrawals to L1 require the batch to be proven and finalized — typically a few hours under healthy prover load, longer under prover congestion. Use Across/Stargate/LiFi for fast exits at the cost of bridge fees.
  • Bridged USDC on Era was historically the canonical token; Circle now ships native CCTP USDC separately. Token-route logic that assumes one canonical USDC will mismatch — check Circle's address registry rather than guessing.
07Alternatives