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/
Transports
The API currently supports HTTP(s) transports only. Requests should be sent with the POST method and Content-Type: application/json.
Payload Structure
Each request has a payload structured like the following:
{"id": 20,// a unique request identifier, may be a number or string"jsonrpc": "2.0",// the jsonrpc version, 2.0 is the only currently accepted value"method": "l2_getBlockByNumber",// the rpc method to call"params": [1] // an array of parameters to pass to the method}
Each response will include a result and an optional error.
{"id": 20,"jsonrpc": "2.0","result": { ... },}
Methods
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.