ZKs specific JSON-RPC API
Overview of the JSON-RPC API methods specific to Cronos zkEVM, detailing operations and functionalities within the Cronos zkEVM ecosystem.
Last updated
Overview of the JSON-RPC API methods specific to Cronos zkEVM, detailing operations and functionalities within the Cronos zkEVM ecosystem.
Last updated
Based on ZK Stack - besides stand Ethereum JSON-RPCs, Cronos zkEVM provides a suite of JSON-RPC API methods designed for seamless interaction with its ecosystem. These methods offer developers the tools needed to integrate their applications with Cronos zkEVM's features, enhancing the capability to perform transactions, query network data, and interact with smart contracts efficiently. This guide builds on the , adapting it to the features and requirements of the Cronos zkEVM chain environment.
zk_estimateFee
Estimates the fee for a given call request.
CallRequest - object
from: DATA, 20 bytes - Sender address. Arbitrary if not provided.
to: DATA, 20 bytes - Recipient address. Required for eth_call
.
gas: QUANTITY - Gas limit for the transaction. Defaults if not provided.
gas_price: QUANTITY - Gas price for the transaction. Defaults if not provided.
max_fee_per_gas: QUANTITY - Maximum fee per unit of gas.
max_priority_fee_per_gas: QUANTITY - Maximum priority fee per unit of gas.
value: QUANTITY - Value transferred in the transaction. None for no transfer.
data / input: DATA - Data sent with the transaction. Empty if not provided.
nonce: DATA, 32 bytes - Transaction nonce.
transaction_type: QUANTITY, 8 bytes - Type of the transaction.
access_list: AccessList - EIP-2930 access list.
customData: OBJECT - Extra parameters for EIP712 transactions, like paymasterParams
or customSignature
.
The method returns an object containing the estimated gas and fee details for the given call request.
gas_limit: QUANTITY, 32 bytes - The maximum amount of gas that can be used.
max_fee_per_gas: QUANTITY, 32 bytes - The maximum fee per unit of gas that the sender is willing to pay.
max_priority_fee_per_gas: QUANTITY, 32 bytes - The maximum priority fee per unit of gas to incentivize miners.
gas_per_pubdata_limit: QUANTITY, 32 bytes - The gas limit per unit of public data.
zks_estimateGasL1ToL2
Estimates the gas required for an L1 to L2 transaction.
CallRequest - object
from: DATA, 20 bytes - Sender address. Arbitrary if not provided.
to: DATA, 20 bytes - Recipient address. Required for eth_call
.
gas: QUANTITY - Gas limit for the transaction. Defaults if not provided.
gas_price: QUANTITY - Gas price for the transaction. Defaults if not provided.
max_fee_per_gas: QUANTITY - Maximum fee per unit of gas.
max_priority_fee_per_gas: QUANTITY - Maximum priority fee per unit of gas.
value: QUANTITY - Value transferred in the transaction. None for no transfer.
data / input: DATA - Data sent with the transaction. Empty if not provided.
nonce: DATA, 32 bytes - Transaction nonce.
transaction_type: QUANTITY, 8 bytes - Type of the transaction.
access_list: AccessList - EIP-2930 access list.
customData: OBJECT - Extra parameters for EIP712 transactions, like paymasterParams
or customSignature
.
QUANTITY, 32 bytes - The estimated gas amount in hexadecimal format, representing the number of gas units required.
zks_getBridgehubContract
Retrieves the bridge hub contract address.
None
DATA, 20 bytes - a single string value representing the bridge hub contract address.
zks_getMainContract
Retrieves the main contract address.
None
DATA, 20 bytes - address of the main contract.
zks_getTestnetPaymaster
Retrieves the testnet paymaster address, specifically for interactions within the Cronos zkEVM Testnet environment. Note: This method is only applicable for Cronos zkEVM Testnet.
None
DATA, 20 bytes - address of the testnet paymaster.
zks_getBridgeContracts
Retrieves the addresses of canonical bridge contracts for Cronos zkEVM.
None
Object containing the addresses of bridge contracts.
l1Erc20DefaultBridge: DATA, 20 bytes - address of the default ERC-20 bridge on Layer 1.
l2Erc20DefaultBridge: DATA, 20 bytes - address of the default ERC-20 bridge on Layer 2.
l1WethBridge: DATA, 20 bytes - address of the Wrapped Ethereum (WETH) bridge on Layer 1.
l2WethBridge: DATA, 20 bytes - address of the Wrapped Ethereum (WETH) bridge on Layer 2.
zks_L1ChainId
Retrieves the L1 chain ID.
None
QUANTITY, 8 bytes - The hexadecimal representation of the L1 chain ID.
zks_getBaseTokenL1Address
Retrieves the L1 base token address.
None
DATA, 20 bytes - Layer 1 Ethereum address of base token.
zks_getConfirmedTokens
Lists confirmed tokens. Confirmed in the method name means any token bridged to Cronos zkEVM via the official bridge.
The tokens are returned in alphabetical order by their symbol. This means the token id is its position in an alphabetically sorted array of tokens.
uint32 - token id from which to start.
uint8 - maximum number of tokens to list.
Array of token objects, each containing details about a specific confirmed token.
l1Address: DATA, 20 bytes - Layer 1 Ethereum address of the token.
l2Address: DATA, 20 bytes - Layer 2 Cronos zkEVM address of the token.
name: String - name of the token.
symbol: String - symbol of the token.
decimals: uint8 - number of decimals the token uses.
zks_getAllAccountBalances
Gets all account balances for a given address.
DATA, 20 bytes - account address.
The method returns an object with token addresses as keys and their corresponding balances as values. Each key-value pair represents the balance of a specific token held by the account.
<DATA, 20 bytes>: QUANTITY, 32 bytes - The token address is the key, and its value is the balance of that token held by the account, represented in the smallest unit of the token (e.g., wei for ETH).
zks_getL2ToL1MsgProof
Retrieves the proof for an L2 to L1 message.
uint32 - L2 block number.
DATA, 20 bytes - sender's address.
DATA, 32 bytes - message hash.
number - Optional. The log position in L2.
zks_getL2ToL1LogProof
Retrieves the log proof for an L2 to L1 transaction.
DATA, 32 bytes - transaction hash.
integer - Optional. Index of the log.
proof: Array of DATA, 32 bytes - array of strings, each representing a piece of the proof for the specified log.
id: integer - identifier of the log within the transaction.
root: DATA, 32 bytes - root hash of the proof, anchoring it to a specific state in the blockchain.
Example Response
zks_L1BatchNumber
Retrieves the current L1 batch number.
None
QUANTITY, 8 bytes - hexadecimal representation of the current L1 batch number.
zks_getBlockDetails
Retrieves details for a given block.
committed
: The batch is closed and the state transition it creates exists on layer 1.
proven
: The batch proof has been created, submitted, and accepted on layer 1.
executed
: The batch state transition has been executed on L1; meaning the root state has been updated.
The method requires a single parameter to specify the block whose details are to be retrieved.
uint32 - number of the block.
Object containing detailed information about the specified block.
number: uint32 - number of the block.
l1BatchNumber: uint32 - corresponding L1 batch number.
timestamp: uint32 - Unix timestamp when the block was committed.
l1TxCount: uint32 - number of L1 transactions included in the block.
l2TxCount: uint32 - number of L2 transactions included in the block.
rootHash: DATA, 32 bytes - root hash of the block's state after execution.
status: String - current status of the block (e.g., verified, executed).
commitTxHash: DATA, 32 bytes - transaction hash of the commit operation on L1.
committedAt: String - timestamp when the block was committed on L1.
proveTxHash: DATA, 32 bytes - transaction hash of the proof submission on L1.
provenAt: String - timestamp when the proof was submitted on L1.
executeTxHash: DATA, 32 bytes - transaction hash of the execution on L1.
executedAt: String - timestamp when the block execution was completed on L1.
l1GasPrice: uint64 - L1 gas price at the time of the block's execution.
l2FairGasPrice: uint64 - fair gas price on L2 at the time of the block's execution.
baseSystemContractsHashes: Object - A collection of hashes for the base system contracts.
operatorAddress: DATA, 20 bytes - address of the operator who committed the block.
protocolVersion: String - version of the protocol the block was committed under.
zks_getTransactionDetails
Retrieves details for a given transaction.
DATA, 32 bytes - hash of the transaction.
Object containing detailed information about the specified transaction.
isL1Originated: Boolean - Indicates whether the transaction originated on Layer 1.
status: String - current status of the transaction (e.g., verified).
fee: QUANTITY, 32 bytes - transaction fee.
gasPerPubdata: QUANTITY, 32 bytes - gas amount per unit of public data for this transaction.
initiatorAddress: DATA, 20 bytes - address of the transaction initiator.
receivedAt: String - timestamp when the transaction was received.
ethCommitTxHash: DATA, 32 bytes - transaction hash of the commit operation.
ethProveTxHash: DATA, 32 bytes - transaction hash of the proof submission.
ethExecuteTxHash: DATA, 32 bytes - transaction hash of the execution.
zks_getRawBlockTransactions
Lists transactions in a block without processing them.
uint32 - number of the block.
Array of objects, each representing a raw transaction within the specified block. Each transaction object includes common data, execution details, a timestamp, and the raw transaction bytes.
common_data: Object - general information about the L2 transaction, such as nonce, fees, initiator address, signature, transaction type, input data, and paymaster parameters.
execute: Object - Details regarding the execution of the transaction, including the contract address, calldata, value, and any factory dependencies.
received_timestamp_ms: Number - timestamp when the transaction was received, in milliseconds.
raw_bytes: DATA, 32 bytes - raw bytes of the transaction as a hexadecimal string.
zks_getL1BatchDetails
Retrieves details for a given L1 batch.
uint32 - L1 batch number.
Object of details for L1 batch.
number: uint32 - L1 batch number.
timestamp: uint64 - Unix timestamp when the batch was processed.
l1TxCount: uint32 - number of L1 transactions included in the batch.
l2TxCount: uint32 - number of L2 transactions associated with this batch.
rootHash: DATA, 32 bytes - root hash of the state after processing the batch.
status: String - current status of the batch (e.g., verified).
commitTxHash: DATA, 32 bytes - Ethereum transaction hash for the commit operation.
committedAt: String - timestamp when the batch was committed on Ethereum.
proveTxHash: DATA, 32 bytes - Ethereum transaction hash for the proof submission.
provenAt: String - timestamp when the proof was submitted.
executeTxHash: DATA, 32 bytes - Ethereum transaction hash for the execution.
executedAt: String - timestamp when the execution was completed.
l1GasPrice: uint64 - gas price on L1 at the time of batch processing.
l2FairGasPrice: uint64 - fair gas price on L2 at the time of batch processing.
baseSystemContractsHashes: Object - Hashes of the base system contracts involved in the batch.
zks_getL1BatchBlockRange
Returns the range of blocks contained within a batch given by the batch number.
The range is provided by the beginning and end block numbers in hexadecimal.
L1BatchNumber - the layer 1 batch number.
Array of Hex Strings - array containing the beginning and end block numbers in hexadecimal.
zks_getL1GasPrice
Retrieves the current L1 gas price.
None
QUANTITY, 8 bytes - current L1 gas price in hexadecimal format, representing the amount of wei per unit of gas.
zks_getFeeParams
Retrieves the current fee parameters.
None
Object
V2: Object - fee parameter configuration for the current version of the Cronos zkEVM protocol.
config: Object - settings related to transaction fee computation.
minimal_l2_gas_price: uint64 - minimal gas price on L2.
compute_overhead_part: float64 - compute overhead part in fee calculation.
pubdata_overhead_part: float64 - public data overhead part in fee calculation.
batch_overhead_l1_gas: uint64 - overhead in L1 gas for a batch of transactions.
max_gas_per_batch: uint64 - maximum gas allowed per batch.
max_pubdata_per_batch: uint64 - maximum amount of public data allowed per batch.
l1_gas_price: uint64 - current L1 gas price.
l1_pubdata_price: uint64 - price of storing public data on L1.
zks_getProtocolVersion
Gets the protocol version.
uint16 - Optional. Specific version ID.
Object
version_id: uint16 - protocol version ID.
timestamp: uint64 - Unix timestamp of the version's activation.
verification_keys_hashes: Object - Contains the hashes of various verification keys used in the protocol.
base_system_contracts: Object - Hashes of the base system contracts, like the bootloader and default account abstraction (AA).
l2_system_upgrade_tx_hash: DATA, 32 bytes - hash of the transaction used for the system upgrade, if any.