Getting Started


While most of the existing SDKs should work out of the box, deploying smart contracts or using unique ZKsync features, like account abstraction, requires providing additional fields to those that Ethereum transactions have by default.

To provide easy access to all the features of ZKsync Era, the zksync2 Python SDK was created, which is made in a way that has an interface very similar to those of In fact, is a peer dependency of our library and most of the objects exported by zksync2 inherit from the corresponding objects and override only the fields that need to be changed.


Adding dependencies

To install ZKsync Era, run the command below in your terminal.

pip install zksync2

Connecting to ZKsync Era

Once you have all the necessary dependencies, connect to ZKsync Era using the endpoint of the operator node.

from zksync2.module.module_builder import ZkSyncBuilder
sdk ="")

Get chain id:

chain_id = zk_web3.zksync.chain_id

Get block number:

block_number = zk_web3.zksync.block_number

Get the transaction by hash:

transaction = zksync_web3.zksync.eth_get_transaction_by_hash(hash);

Also, the following examples demonstrate how to:

  1. Deposit ETH and tokens from Ethereum into ZKsync Era
  2. Transfer ETH and tokens on ZKsync Era
  3. Withdraw ETH and tokens from ZKsync Era to Ethereum
  4. Use paymaster to pay fee with token

Full code for all examples is available here. Examples are configured to interact with ZKsync Era and Sepolia test networks.

Made with ❤️ by the ZKsync Community