Python SDK

Getting Started

A guide to getting started with the zksync2-python.

This guide will help you get started with the zksync2-python, from connecting to the network to performing basic operations.

Check the installation guide for instructions.

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 = ZkSyncBuilder.build("https://sepolia.era.zksync.dev")

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);

Examples

Also, the following examples demonstrate how to:

  1. Deposit ETH and tokens from Ethereum into ZKsync Era
  1. Transfer ETH and tokens on ZKsync Era
  1. Withdraw ETH and tokens from ZKsync Era to Ethereum
  1. Use paymaster to pay fees with tokens
Examples are configured to interact with ZKsync Era and Sepolia test networks.

Made with ❤️ by the ZKsync Community