Skip to content

getL2HashFromPriorityOp

Returns the hash of the L2 priority operation from a given L1 transaction receipt.

Import

import { getL2HashFromPriorityOp } from 'viem/zksync'

Usage

example.ts
import { client, zksyncClient } from './config'
import { getL2HashFromPriorityOp } from 'viem/zksync'
 
const receipt = await client.waitForTransactionReceipt({
  hash: '0x...'
})
const l2Hash = getL2HashFromPriorityOp(
  receipt,
  await zksyncClient.getMainContractAddress()
)

Returns

Hash

The hash of the L2 priority operation.

Parameters

receipt

The L1 transaction receipt.

const l2Hash = getL2HashFromPriorityOp(
  receipt, 
  '0x14b947814912c71bdbc3275c143a065d2ecafaba'
)

zksync

  • Type: Address

The address of the ZKsync Era main contract.

const l2Hash = getL2HashFromPriorityOp(
  receipt, 
  '0x14b947814912c71bdbc3275c143a065d2ecafaba'
)