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:
- Deposit ETH and tokens from Ethereum into ZKsync Era
- Transfer ETH and tokens on ZKsync Era
- Withdraw ETH and tokens from ZKsync Era to Ethereum
- Use paymaster to pay fees with tokens
Examples are configured to interact with
ZKsync Era
and Sepolia
test networks.