getL2TransactionHash
Computes the L2 transaction hash from an L1 TransactionDeposited
log.
Import
import { getL2TransactionHash } from 'viem'
Usage
import { extractTransactionDepositedLogs, getL2TransactionHash } from 'viem'
const receipt = await client.getTransactionReceipt({
hash: '0xa08acae48f12243bccd7153c88d892673d5578cce4ee9988c0332e8bba47436b',
})
const [log] = extractTransactionDepositedLogs(receipt)
const l2Hash = getL2TransactionHash({ log })
Returns
Hex
The L2 transaction hash.
Parameters
log
- Type:
Log
An L1 TransactionDeposited
log.
const l2Hash = getL2TransactionHash({
log: {
args: {
from: '0x1a1E021A302C237453D3D45c7B82B19cEEB7E2e6',
opaqueData: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045000000000000520800',
to: '0x1a1E021A302C237453D3D45c7B82B19cEEB7E2e6',
version: 0n,
},
blockHash: '0x634c52556471c589f42db9131467e0c9484f5c73049e32d1a74e2a4ce0f91d57',
eventName: 'TransactionDeposited',
logIndex: 109,
}
})