zkevm_virtualBatchNumber | zkEVM

Polygon zkEVM API method that returns the current virtual batch number.

In the Polygon zkEVM, transactions are grouped into batches. A virtual batch is a batch that is in the process of being created and has not yet been verified. The virtual batch number represents the next batch to be verified using zero-knowledge proofs.

Parameters

  • none

Response

  • result — the hexadecimal value of the latest virtual batch number on the Polygon zkEVM network.

zkevm_virtualBatchNumber code examples

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

web3.extend({
    property: 'zkEVM',
    methods: [{
      name: 'virtualBatchNumber',
      call: 'zkevm_virtualBatchNumber',
      params: 0,
      inputFormatter: null,
      outputFormatter: null
    }]
  });

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

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

const virtualBatchNumber = async () => {

    // This will return the value in Hex
    const currentVirtualBatchNumber = await provider.send("zkevm_virtualBatchNumber");
    console.log(`Current Virtual Batch Number: ${currentVirtualBatchNumber}`);
};

virtualBatchNumber();

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

Try the zkevm_virtualBatchNumber RPC method yourself

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