Introduction

For local testing, we recommend setting up an in-memory node and forking mainnet.

This documentation explains the basics of the ZKsync Era Node.

Disclaimers

  • The ZKsync node software is provided "as-is" without any express or implied warranties.
  • The ZKsync node is in the beta phase, and should be used with caution.
  • The ZKsync node is a read-only replica of the main node.
  • The ZKsync node is not going to be the consensus node.
  • Running a sequencer node is currently not possible and there is no option to vote on blocks as part of the consensus mechanism or fork-choice like on Ethereum.

What is the ZKsync Node?

The ZKsync node is a read-replica of the main (centralized) node that can be run by anyone. It functions by fetching data from the ZKsync API and re-applying transactions locally, starting from the genesis block. The ZKsync node shares most of its codebase with the main node. Consequently, when it re-applies transactions, it does so exactly as the main node did in the past.

In Ethereum terms, the current state of the ZKsync node represents an archive node, providing access to the entire history of the blockchain.

High-level Overview

At a high level, the ZKsync node can be seen as an application that has the following modules:

  • API server that provides the publicly available Web3 interface.
  • Synchronization layer that interacts with the main node and retrieves transactions and blocks to re-execute.
  • Sequencer component that actually executes and persists transactions received from the synchronization layer.
  • Several checker modules that ensure the consistency of the ZKsync node state.

With the ZKsync node, you are able to:

  • Locally recreate and verify the ZKsync Era mainnet/testnet state.
  • Interact with the recreated state in a trustless way (in a sense that the validity is locally verified, and you should not rely on a third-party API ZKsync Era provides).
  • Use the Web3 API without having to query the main node.
  • Send L2 transactions (that will be proxied to the main node).

With the ZKsync node, you can not:

  • Create L2 blocks or L1 batches on your own.
  • Generate proofs.
  • Submit data to L1.

A more detailed overview of the ZKsync node's components is provided in the components section.

API Overview

API exposed by the ZKsync node strives to be Web3-compliant. If some method is exposed but behaves differently compared to Ethereum, it should be considered a bug. Please report such cases.

eth_ Namespace

Data getters in this namespace operate in the L2 space: require/return L2 block numbers, check balances in L2, etc.

Available methods:

MethodNotes
eth_blockNumber
eth_chainId
eth_call
eth_estimateGas
eth_gasPrice
eth_newFilterMaximum amount of installed filters is configurable
eth_newBlockFilterSame as above
eth_newPendingTransactionsFilterSame as above
eth_uninstallFilter
eth_getLogsMaximum amount of returned entities can be configured
eth_getFilterLogsSame as above
eth_getFilterChangesSame as above
eth_getBalance
eth_getBlockByNumber
eth_getBlockByHash
eth_getBlockTransactionCountByNumber
eth_getBlockTransactionCountByHash
eth_getCode
eth_getStorageAt
eth_getTransactionCount
eth_getTransactionByHash
eth_getTransactionByBlockHashAndIndex
eth_getTransactionByBlockNumberAndIndex
eth_getTransactionReceipt
eth_protocolVersion
eth_sendRawTransaction
eth_syncingEN is considered synced if it's less than 11 blocks behind the main node.
eth_coinbaseAlways returns a zero address
eth_accountsAlways returns an empty list
eth_getCompilersAlways returns an empty list
eth_hashrateAlways returns zero
eth_getUncleCountByBlockHashAlways returns zero
eth_getUncleCountByBlockNumberAlways returns zero
eth_miningAlways returns false

PubSub

Only available on the WebSocket servers.

Available methods:

MethodNotes
eth_subscribeMaximum amount of subscriptions is configurable
eth_subscription

net_ Namespace

Available methods:

MethodNotes
net_version
net_peer_countAlways returns 0
net_listeningAlways returns false

web3_ Namespace

Available methods:

MethodNotes
web3_clientVersion

debug namespace

The debug namespace gives access to several non-standard RPC methods, which will allow developers to inspect and debug calls and transactions.

This namespace is disabled by default and can be configured via setting EN_API_NAMESPACES as described in the example config.

Available methods:

MethodNotes
debug_traceBlockByNumber
debug_traceBlockByHash
debug_traceCall
debug_traceTransaction

zks namespace

This namespace contains rollup-specific extensions to the Web3 API. Note that only methods specified in the documentation are considered public. There may be other methods exposed in this namespace, but undocumented methods come without any kind of stability guarantees and can be changed or removed without notice.

Always refer to the documentation linked above and API reference documentation to see the list of stabilized methods in this namespace.

en namespace

This namespace contains methods that ZKsync nodes call on the main node while syncing. If this namespace is enabled other ZKsync nodes can sync from this node.


Made with ❤️ by the ZKsync Community