For the complete documentation index, see llms.txt. This page is also available as Markdown.

zks_getL2ToL1LogProof - zkSync

Example code for the zks_getL2ToL1LogProof JSON-RPC method. Сomplete guide on how to use zks_getL2ToL1LogProof JSON-RPC in GetBlock.io Web3 documentation.

Retrieves the log proof for an L2 to L1 transaction. The log proof can only be generated after the corresponding L2 transaction has been finalized (executed) on L1. Use this proof to claim withdrawals on L1.

Parameters

Parameter
Type
Required
Description

txHash

string

Yes

Transaction hash (32 bytes)

logIndex

integer

No

Index of the log (optional for EraVM chains)

Request Example

curl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "zks_getL2ToL1LogProof",
    "params": [
        "0x2a1c6c74b184965c0cb015aae9ea134fd96215d2e4f4979cfec12563295f610e"
    ],
    "id": "getblock.io"
}'
import axios from 'axios';

const data = JSON.stringify({
    "jsonrpc": "2.0",
    "method": "zks_getL2ToL1LogProof",
    "params": [
        "0x2a1c6c74b184965c0cb015aae9ea134fd96215d2e4f4979cfec12563295f610e"
    ],
    "id": "getblock.io"
});

const config = {
    method: 'post',
    url: 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers: {
        'Content-Type': 'application/json'
    },
    data: data
};

axios(config)
    .then(response => console.log(JSON.stringify(response.data, null, 2)))
    .catch(error => console.log(error));

Response Example

Response Parameters

Field
Type
Description

result.proof

array of string

Array of 32-byte hashes — the Merkle proof for the log

result.id

integer

Identifier of the log within the transaction

result.root

string

Root hash anchoring the proof

result.batchNumber

integer

L1 batch number where the log was executed

Use Cases

  • L2 → L1 withdrawals — required to finalize on L1

  • Cross-chain messaging proofs

  • Trust-minimized L2 → L1 message verification

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid <ACCESS-TOKEN>

429

Too Many Requests

Rate limit exceeded for your plan

SDK Integration

Last updated

Was this helpful?