zkevm_getBatchByNumber | zkEVM

Polygon zkEVM API method that returns information about a specific batch of transactions based on the batch number.

👍

Get you own node endpoint today

Start for free and get your app to production levels immediately. No credit card required.

You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

  • batchNumber — an integer or hexadecimal string representing the batch number.

Response

  • number — a hexadecimal value representing the batch number.
  • coinbase — the address of the sequencer that virtualized this batch, for now, it refers to the Trusted Sequencer address.
  • stateRoot — the root of the final state of the batch.
  • globalExitRoot — the root of the tree that represents the deposits of the bridge (multichain). Root containing all the local exit roots of all the connected networks (in this case, a local exit root for L1 and another for L2).
  • localExitRoot — the root of the tree that represents the deposits of the zkEVM.
  • accInputHash — the hash of the inputs used to build the zero-knowledge proof for a batch. Also included in the input is the accInputHash from the previous batch, used for the aggregation of zero-knowledge proofs.
  • timestamp — the hexadecimal value of the Unix timestamp representing the exact time of the batch being verified.
  • sendSequencesTxHash — the hash of the transaction that virtualized this batch. null when it's not virtualized yet.
  • verifyBatchTxHash — the hash of the transaction that verified this batch. null when it's not verified yet.
  • transactions[] — an array of hashes of all the transactions included in the batch.

zkevm_getBatchByNumber code examples

const Web3 = require("web3");
const NODE_URL = "YOUR_CHAINSTACK_ENDPOINT";
const web3 = new Web3(NODE_URL);

web3.extend({
    property: 'zkEVM',
    methods: [{
      name: 'getBatchByNumber',
      call: 'zkevm_getBatchByNumber',
      params: 1,
      inputFormatter: null,
      outputFormatter: null
    }]
  });

async function getBatchByNumber(batchNumber) {
  const output = await web3.zkEVM.getBatchByNumber(batchNumber)
  console.log(output)
}

getBatchByNumber(8128);
const ethers = require('ethers');
const NODE_URL = "YOUR_CHAINSTACK_ENDPOINT";
const provider = new ethers.JsonRpcProvider(NODE_URL);

const getBatchByNumber = async (batchNumber) => {
    const batch = await provider.send("zkevm_getBatchByNumber", [batchNumber]);
    console.log(batch);
}

getBatchByNumber(8128);

from web3 import Web3
node_url = "YOUR_CHAINSTACK_ENDPOINT"
web3 = Web3(Web3.HTTPProvider(node_url))
output = web3.provider.make_request('zkevm_getBatchByNumber', [8128])
print(output)

Try the zkevm_getBatchByNumber RPC method yourself

Language
Click Try It! to start a request and see the response here!