Skip to main content

At a glance

  • Factory: createEthersSdk(client) → EthersSdk
  • Composed resources: sdk.deposits, sdk.withdrawals, sdk.helpers
  • Client vs SDK: the client wires RPC/signing; the sdk adds high-level flows (quote → prepare → create → wait) and convenience helpers.

Import

Quick start

createEthersSdk(client) → EthersSdk

Returns: EthersSdk
The SDK composes the client with resources: deposits, withdrawals, and convenience helpers.

EthersSdk interface

deposits: DepositsResource

L1 → L2 flows. See Deposits.

withdrawals: WithdrawalsResource

L2 → L1 flows. See Withdrawals.

helpers

Utilities for chain addresses, connected contracts, and L1↔L2 token mapping.

addresses() → Promise<ResolvedAddresses>

Resolve core addresses (Bridgehub, routers, vaults, base-token system).

contracts() → Promise<{ ...contracts }>

Connected ethers.Contract instances for all core contracts.

One-off contract getters

l1AssetRouter() → Promise<Contract> l1NativeTokenVault() → Promise<Contract> l1Nullifier() → Promise<Contract>

baseToken(chainId?: bigint) → Promise<Address>

L1 address of the base token for the current (or supplied) L2 chain.

l2TokenAddress(l1Token: Address) → Promise<Address>

L2 token address for an L1 token.
  • Handles ETH special case (L2 ETH placeholder).
  • If token is the chain’s base token, returns the L2 base-token system address.
  • Otherwise queries IL2NativeTokenVault.l2TokenAddress.

l1TokenAddress(l2Token: Address) → Promise<Address>

L1 token for an L2 token via IL2AssetRouter.l1TokenAddress. ETH placeholder resolves to canonical ETH.

assetId(l1Token: Address) → Promise<Hex>

bytes32 asset ID via L1NativeTokenVault.assetId (ETH handled canonically).

Notes & pitfalls

  • Client first: You must construct the client with { l1, l2, signer } before creating the SDK.
  • Chain-derived behavior: helpers pull from on-chain sources; results depend on the connected networks.
  • Error model: resource methods throw typed errors; prefer try* variants on resources for result objects.