Last updated
Last updated
Zkopru nodes offer an RPC API for accessing information about the L2 network and the underlying L1 network. The RPC format is similar to that of Ethereum. One major difference is not all numbers are hexadecimal. Any numbers without a 0x prefix should be assumed to be decimal.
Zkopru nodes will proxy web3 requests to the underlying Ethereum node. For example, eth_blockNumber
will return a valid response. Zkopru node URLs can be used as web3 providers.
A testnet API can be accessed at https://node.zkopru.network/
The API currently supports HTTP(s) transports only. Requests should be sent with the POST
method and Content-Type: application/json
.
Each request has a payload structured like the following:
Each response will include a result
and an optional error
.
l1_address
Returns the address of the Zkopru contract on the L1 network.
Params: none
Result: 20 byte address
l1_getVKs
Returns the verifying keys for the current Zkopru network.
Params: none
Result:
l2_syncing
Returns a boolean indicating whether the current node is synchronizing.
Params: none
Result: Boolean
l2_blockCount
Returns the number of blocks that have been submitted to the current Zkopru network. This includes uncles. This is not the same as the block number. The block count will always be greater than or equal to the block number.
Params: none
Result: Integer
l2_blockNumber
Returns the number of blocks in the canonical Zkopru chain. This is referred to as the canonical number in object properties.
If you're not sure whether to use the block count or block number, you probably want block number.
Params: none
Result: Integer
l2_getBlockByNumber
Returns a block by canonical number. Optionally include uncle blocks for the same number. If uncles are not included a property uncleCount
will be present on the response.
Params: index (Integer)
, includeUncles (Boolean)
Result: Object
Example request:
Example response:
l2_getBlockByIndex
Returns a block by block index. This is not the canonical number but the block index in the network, including uncles.
Params: index (Integer)
Result: Object
l2_getBlockByHash
Returns a Zkopru block by hash.
Params: hash (String)
Result: Object
l2_getTransactionByHash
Returns transaction data by hash.
Params: hash (String)
Result: Object
Example request:
Example response:
l2_getRegisteredTokens
Returns the tokens registered for use in the network.
Params: none
Result: Object
Example response: