ZKsync Era is a high-performance Layer 2 scaling solution that maintains full compatibility with the Ethereum ecosystem. It supports the standard Ethereum JSON-RPC API, enabling developers to interact with the network using familiar tools and workflows. However, due to its unique architecture as a zkRollup, there are important distinctions and considerations when working with ZKsync-specific implementations.
This guide provides a comprehensive overview of supported JSON-RPC methods, key differences from Ethereum L1, and practical usage examples to help developers build efficiently on ZKsync Era.
Key Differences from Ethereum L1
While ZKsync Era aligns closely with Ethereum's interface, certain structural differences impact how some RPC methods behave:
Block Data Retrieval Methods
Methods such as eth_getBlockByHash, eth_getBlockByNumber, and Geth’s pubsub API eth_subscribe with the newHeads parameter do not return actual values for receiptsRoot, transactionsRoot, or stateRoot. Instead, these fields contain zero values.
👉 Discover how ZKsync’s architecture enhances scalability while preserving security.
This behavior occurs because ZKsync’s Layer 2 blocks don’t include a state root—only L1 batches have this concept. Developers should account for this when validating block integrity or building explorers and analytics tools.
Unsupported Method: eth_sendTransaction
The eth_sendTransaction method is intentionally not supported in ZKsync. To send transactions, use eth_sendRawTransaction with a pre-signed transaction payload. This design enforces security best practices and aligns with non-interactive transaction submission models used in modern wallets and dApps.
Core JSON-RPC Methods Overview
Below is a detailed breakdown of essential JSON-RPC methods available on ZKsync Era, including parameters, return types, and usage examples.
eth_chainId
Retrieves the current chain ID of the ZKsync network.
- Parameters: None
- Returns:
QUANTITY– Hexadecimal representation of the chain ID.
Example Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "eth_chainId",
"params": []
}Example Response:
{
"jsonrpc": "2.0",
"result": "0x144",
"id": 1
}Chain ID 0x144 corresponds to ZKsync Era Mainnet.eth_call
Executes a read-only message call immediately without creating a transaction.
Parameters:
Object: Transaction call object (to,data, etc.)BlockIdVariant(optional): Target block (e.g.,"latest")
- Returns:
DATA– Hex-encoded output from the smart contract function.
Useful for querying contract state without gas costs.
eth_estimateGas
Estimates the gas required to execute a transaction.
Parameters:
Object: Transaction objectuint32(optional): Block number
- Returns:
QUANTITY– Estimated gas in hexadecimal format.
Note: Thefromfield cannot reference a smart contract unless it's aSmartAccount.
eth_gasPrice
Returns the current average gas price in gwei.
- Returns:
QUANTITY– Gas price in hexadecimal, useful for dynamic fee calculation.
This value helps optimize transaction costs based on real-time network demand.
👉 Learn how to optimize gas efficiency across Layer 2 networks.
eth_newFilter, eth_newBlockFilter, eth_newPendingTransactionFilter
These methods create filters to monitor events, new blocks, or pending transactions respectively.
- Returns:
QUANTITY– Unique filter identifier (hex string)
Filters enable real-time monitoring of blockchain activity and are essential for event-driven applications like decentralized exchanges or alert systems.
eth_uninstallFilter
Removes an existing filter by ID.
- Returns:
Boolean–trueif successfully uninstalled
Use this method to clean up unused filters and free node resources.
eth_getLogs, eth_getFilterLogs, eth_getFilterChanges
Retrieve logs matching filter criteria:
eth_getLogs: Direct log query using filter conditionseth_getFilterLogs: Get all logs for a previously created filtereth_getFilterChanges: Get logs since last poll (ideal for incremental updates)
Each log includes details like address, topics, transaction hash, and removal status (due to reorgs).
eth_getBalance
Gets the balance of an account at a specific block.
Parameters:
- Account address (
DATA, 20 bytes) - Block identifier (
latest,pending, etc.)
- Account address (
- Returns: Balance in gwei (hex)
Critical for wallet interfaces and balance tracking services.
eth_getBlockByNumber, eth_getBlockByHash
Fetches block data by number or hash.
- Supports both full transaction objects (
true) or hashes only (false) - Includes metadata like timestamp, gas used, base fee, and L1 batch number
Despite zeroed-out roots (stateRoot, etc.), these methods remain vital for block exploration.
eth_getBlockTransactionCountByNumber, ByHash
Returns the number of transactions in a given block.
- Efficient for analyzing block density without retrieving full data
Useful in dashboards and statistical analysis tools.
eth_getBlockReceipts
Fetches receipts for all transactions in a specified block.
- Includes status, gas used, logs, and effective gas price
- Essential for audit trails and compliance tools
eth_getCode, eth_getStorageAt
getCode: Retrieves contract bytecode at an addressgetStorageAt: Reads raw storage slot value at an index
Both support optional block parameters for historical analysis.
eth_getTransactionCount
Gets the number of transactions sent from an address (nonce).
Used to construct valid transactions and prevent replay attacks.
Transaction Retrieval Methods
ZKsync supports standard Ethereum methods:
eth_getTransactionByHasheth_getTransactionByBlockHashAndIndexeth_getTransactionReceipt
All return detailed metadata including L1 batch association, crucial for cross-layer tracking.
Network & Client Information
eth_protocolVersion: Returns protocol identifier (e.g.,"zks/0.27.0")web3_clientVersion: Returns client software version (e.g.,"ZKsync/v2.0")eth_feeHistory: Provides base fees and rewards over recent blocks (supports EIP-1559 analytics)
Frequently Asked Questions
Why are stateRoot and receiptsRoot zero in block responses?
ZKsync uses zkRollup architecture where state commitments occur at the L1 batch level, not per L2 block. Hence, per-block roots are not applicable and return zero.
Can I use MetaMask with ZKsync Era?
Yes. Configure MetaMask with the correct chain ID (0x144) and RPC URL (https://mainnet.era.zksync.io). Most dApps work seamlessly after configuration.
Is EIP-1559 supported?
Yes. ZKsync Era supports dynamic fee markets via EIP-1559. Use maxFeePerGas and maxPriorityFeePerGas in your transactions.
How do I handle transaction finality?
Finality is determined through L1 confirmation of batch proofs. Monitor L1 contracts like the zkSync contract on Ethereum for proof submission and verification events.
What tools can I use to interact with ZKsync?
You can use standard tools like ethers.js, web3.js, Hardhat, and Foundry. Ensure you're connecting to a ZKsync-compatible RPC endpoint.
Why is eth_sendTransaction not supported?
It's disabled to prevent insecure transaction signing patterns. Always use eth_sendRawTransaction with pre-signed payloads for better control and security.
Keyword Integration Summary
Core keywords naturally integrated throughout:
- ZKsync Era
- JSON-RPC API
- Layer 2 scaling
- Ethereum compatibility
- gas estimation
- transaction receipt
- block data retrieval
- smart contract interaction
These terms reflect common developer search intents and ensure strong SEO performance while maintaining technical accuracy.
👉 Start building on one of the fastest-growing Layer 2 ecosystems today.