
Product
Socket Now Protects the Chrome Extension Ecosystem
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
@layerzerolabs/lz-v2-utilities
Advanced tools
The LayerZero V2 Utilities package provides a set of essential utilities and modules to facilitate the development and integration of applications with various blockchain networks. It includes functions for packet encoding/decoding, precrime configuration parsing, error parsing, and more.
To install the LayerZero V2 Utilities package, you can use npm or yarn:
npm install @layerzerolabs/lz-v2-utilities
or
yarn add @layerzerolabs/lz-v2-utilities
Encodes and decodes packets using the V1 codec.
import { PacketV1Codec } from "@layerzerolabs/lz-v2-utilities";
const packet = {
version: 1,
nonce: '1',
srcEid: 10121,
sender: '0x7Cff4181f857B06114643D495648A95b3E0B0B81',
dstEid: 10108,
receiver: '0x6552e1c444f6a2ce35b22de6a554da8c32c5650db0e0158df2eb0daa51289968',
guid: '0x6552e1c444f6a2ce35b22de6a554da8c32c5650db0e0158df2eb0daa51289968',
message: '0xff',
payload: '',
};
// Encode the packet
const encodedHex = PacketV1Codec.encode(packet);
console.log(`Encoded Packet: ${encodedHex}`);
// Decode the packet
const decodedPacket = PacketV1Codec.from(encodedHex).toPacket();
console.log(`Decoded Packet: ${JSON.stringify(decodedPacket)}`);
Parses the precrime configuration string.
import { parsePrecrimeConfig } from "@layerzerolabs/lz-v2-utilities";
const configHex = '0x0002000000000000000500010000000100000000000000000000000000000000000000000000000000000000000111110000000000000000000000000000000000000000000000000000000000011111';
const config = parsePrecrimeConfig(configHex);
console.log(`Parsed Precrime Config: ${JSON.stringify(config)}`);
Parses the error data.
import { parseError } from "@layerzerolabs/lz-v2-utilities";
import { Interface } from "@ethersproject/abi";
const errorData = "0x08c379a0...";
const intf = new Interface(["function myFunction()"]);
const parsedError = parseError(errorData, intf);
console.log(`Parsed Error: ${parsedError}`);
Pads a hexadecimal address to 32 bytes.
import { hexZeroPadTo32 } from "@layerzerolabs/lz-v2-utilities";
const address = "0x1234567890abcdef1234567890abcdef12345678";
const paddedAddress = hexZeroPadTo32(address);
console.log(`Padded Address: ${paddedAddress}`);
Builds OptionsType.TYPE_1.
import { optionsType1 } from "@layerzerolabs/lz-v2-utilities";
const extraGas = 200000;
const options = optionsType1(extraGas);
console.log(`Options Type 1: ${options}`);
FAQs
LayerZero Utility V2
The npm package @layerzerolabs/lz-v2-utilities receives a total of 37,549 weekly downloads. As such, @layerzerolabs/lz-v2-utilities popularity was classified as popular.
We found that @layerzerolabs/lz-v2-utilities demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.