Skip to main content

What is this?

The ZKsyncOS SDK provides lightweight adapters for ethers and viem to build L1 ↔ L2 flows—deposits and withdrawals—with a small, focused API. You’ll work with:
  • Adapter-level Clients (providers/wallets, resolved addresses, convenience contracts)
  • High-level SDKs (resources for deposits & withdrawals + helpers)
  • ZKsync-specific RPC helpers (client.zks.*)
  • A consistent, typed Error model (ZKsyncError, try* results)

Quick start

What’s documented here

Ethers · Client

Low-level handle: providers/signer, resolved addresses, convenience contracts, ZK RPC access.

Ethers · SDK

High-level deposits/withdrawals plus helpers for addresses, contracts, and token mapping.

Ethers · Deposits

L1 → L2 flow with quote, prepare, create, status, and wait.

Ethers · Withdrawals

L2 → L1 flow with quote, prepare, create, status, wait, and finalize.

Viem · Client

PublicClient/WalletClient integration, resolved addresses, contracts, ZK RPC access.

Viem · SDK

Same high-level surface as ethers, typed to viem contracts.

Viem · Deposits

L1 → L2 flow with quote, prepare, create, status, and wait.

Viem · Withdrawals

L2 → L1 flow with quote, prepare, create, status, wait, and finalize.

Core · ZK RPC

ZKsync-specific RPC: getBridgehubAddress, getL2ToL1LogProof, enhanced receipts.

Core · Error model

Typed ZKsyncError envelope and try* result helpers.

Notes & conventions

  • Standard eth_* RPC should be performed through your chosen base library (ethers / viem).
    The SDK only adds ZKsync-specific RPC via client.zks.* (e.g., getBridgehubAddress, getL2ToL1LogProof, enhanced receipts).
  • Every resource method has a try* variant (e.g., tryCreate) that returns a result object instead of throwing.
    When errors occur, the SDK throws ZKsyncError with a stable envelope (see Error model).
  • Address resolution comes from on-chain lookups and well-known constants. You can override addresses in the client constructor for forks/tests.