@layerzerolabs/lz-proof-utility
TypeScript icon, indicating that this package has built-in type declarations

3.0.17 • Public • Published

@layerzerolabs/lz-proof-utility

The LayerZero Proof Utility package provides a set of essential utilities and modules to facilitate the generation and verification of proofs for various blockchain networks. It includes functions for generating receipt proofs, encoding parameters, and handling state-sync transactions.

Features

  • Proof Generation: Functions for generating receipt proofs and feather proofs.
  • Parameter Encoding: Functions for encoding proof parameters.
  • State-Sync Handling: Functions for handling state-sync transactions in Polygon blocks.

Installation

To install the LayerZero Proof Utility package, you can use npm or yarn:

npm install @layerzerolabs/lz-proof-utility

or

yarn add @layerzerolabs/lz-proof-utility

Usage

Proof Generation

getReceiptProof

Retrieves the receipt proof based on the provided parameters.

import { getReceiptProof } from "@layerzerolabs/lz-proof-utility"

const network = "mainnet"
const block = { /* block object */ }
const transactionReceipts = [ /* array of transaction receipts */ ]
const transactionIndex = 0
const outboundProofType = 1 // MPT
const utilsVersion = 1 // V1

getReceiptProof(network, block, transactionReceipts, transactionIndex, outboundProofType, utilsVersion).then((proof) => {
    console.log(`Receipt Proof: ${proof}`)
})

getFeatherProof

Generates a feather proof based on the utility version.

import { getFeatherProof } from "@layerzerolabs/lz-proof-utility"

const utilsVersion = 1 // V1
const emitterAddress = "0x1234567890abcdef1234567890abcdef12345678"
const packetPayload = "0xabcdef"

const proof = getFeatherProof(utilsVersion, emitterAddress, packetPayload)
console.log(`Feather Proof: ${proof.proof}`)

Parameter Encoding

encodeParams

Encodes the parameters for the proof.

import { encodeParams } from "@layerzerolabs/lz-proof-utility"

const proof = { /* proof object */ }
const outboundProofType = 1 // MPT
const utilsVersion = 1 // V1
const logIndex = 0
const srcEndpointId = 1

const encodedParams = encodeParams(proof, outboundProofType, utilsVersion, logIndex, srcEndpointId)
console.log(`Encoded Params: ${encodedParams}`)

State-Sync Handling

getPolygonStateSyncTxHash

Returns the transaction hash for the state-sync receipt in a Polygon block.

import { getPolygonStateSyncTxHash } from "@layerzerolabs/lz-proof-utility"

const block = { /* block object */ }

const txHash = getPolygonStateSyncTxHash(block)
console.log(`State-Sync Tx Hash: ${txHash}`)

Utility Functions

buffer2hex

Converts a buffer to a hex string.

import { buffer2hex } from "@layerzerolabs/lz-proof-utility"

const buffer = Buffer.from("example")

const hexString = buffer2hex(buffer)
console.log(`Hex String: ${hexString}`)

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.0.2-initia.50initia
3.0.14-aptos.00aptos
2.3.35-aptos.00dev
2.0.12-tron-rc.30tron
3.0.1794latest
3.0.18-ton.136ton

Version History

VersionDownloads (Last 7 Days)Published
3.0.18-ton.136
3.0.18-ton.049
3.0.1794
3.0.16102
3.0.1578
3.0.142
3.0.14-aptos.00
3.0.13-ton.00
3.0.120
3.0.12-ton.01
3.0.110
3.0.11-aptos.00
3.0.100
3.0.91
3.0.80
3.0.8-aptos.00
3.0.71
3.0.60
3.0.50
3.0.40
3.0.30
3.0.20
3.0.2-initia.50
3.0.2-initia.40
3.0.2-initia.30
3.0.2-initia.20
3.0.2-initia.10
3.0.2-initia.00
3.0.10
3.0.00
2.3.45-initia-oft.50
2.3.45-oft-rc.00
2.3.440
2.3.430
2.3.420
2.3.410
2.3.400
2.3.390
2.3.380
2.3.370
2.3.360
2.3.350
2.3.35-aptos.00
2.3.340
2.3.330
2.3.320
2.3.310
2.3.300
2.3.290
2.3.280
2.3.270
2.3.260
2.3.250
2.3.240
2.3.230
2.3.220
2.3.210
2.3.200
2.3.190
2.3.180
2.3.170
2.3.160
2.3.150
2.3.140
2.3.130
2.3.120
2.3.110
2.3.100
2.3.90
2.3.80
2.3.70
2.3.60
2.3.50
2.3.40
2.3.30
2.3.20
2.3.10
2.2.60
2.2.50
2.2.40
2.2.30
2.2.20
2.2.10
2.2.00
2.1.270
2.1.260
2.1.251
2.1.240
2.1.230
2.1.220
2.1.210
2.1.200
2.1.190
2.1.180
2.1.170
2.1.160
2.1.151
2.1.140
2.1.130
2.1.120
2.1.110
2.1.100
2.1.90
2.1.80
2.1.70
2.1.60
2.1.50
2.1.40
2.1.30
2.1.20
2.1.10
2.1.00
2.0.250
2.0.240
2.0.230
2.0.23-rc.00
2.0.220
2.0.210
2.0.200
2.0.19-rc.10
2.0.19-00
2.0.19-rc.01
2.0.180
2.0.170
2.0.160
2.0.150
2.0.140
2.0.130
2.0.12-tron-rc.30
2.0.120
2.0.12-tron-rc.20
2.0.110
2.0.10-tron0
2.0.90
2.0.80
2.0.70
2.0.60
2.0.50
2.0.40
2.0.4-rc.00
2.0.30
2.0.20
2.0.10
1.5.780
1.5.770
1.5.760
1.5.750
1.5.74-rc.10
1.5.730
1.5.720
1.5.710
1.5.700
1.5.690
1.5.69-testnet-v20
1.5.680
1.5.670
1.5.660
1.5.650
1.5.640
1.5.630
1.5.620
1.5.61-tron0
1.5.610
1.5.600
1.5.590
1.5.580
1.5.560
1.5.550
1.5.540
1.5.530
1.5.53-rc.10
1.5.520
1.5.510
1.5.500
1.5.490
1.5.47-rc.40
1.5.480
1.5.47-rc.20
1.5.47-rc.10
1.5.47-rc.00
1.5.470
1.5.460
1.5.450
1.5.440
1.5.430
1.5.420
1.5.410
1.5.400
1.5.380
1.5.370
1.5.360
1.5.350
1.5.340
1.5.330
1.5.320
1.5.310
1.5.300
1.5.290
1.5.270
1.5.260
1.5.250
1.5.240
1.5.230
1.5.220
1.5.210
1.5.200
1.5.190
1.5.180
1.5.170
1.5.160
1.5.150
1.5.140
1.5.130
1.5.120
1.5.110
1.5.100
1.5.90
1.5.80
1.5.70
1.5.60
1.5.50
1.5.41
1.5.3-robintest.11
1.5.30
1.5.20
1.5.10
0.0.30

Package Sidebar

Install

npm i @layerzerolabs/lz-proof-utility

Weekly Downloads

369

Version

3.0.17

License

BUSL-1.1

Unpacked Size

145 kB

Total Files

9

Last publish

Collaborators

  • layerzero-bot