Skip to main content
Version: Endpoint V2

LayerZero V2 Solidity Contract Standards

LayerZero enable seamless cross-chain messaging, configurations for security, and other quality of life improvements to simplify cross-chain development.

Solidity Contract Standards

Solidity Protocol Configurations


info

To find all of LayerZero's contracts visit the LayerZero V2 Protocol Repo.

Installation

To start sending cross-chain messages with LayerZero, you can install the OApp Contract Package to an existing project:

npm install @layerzerolabs/lz-evm-oapp-v2
info

LayerZero contracts work with both OpenZeppelin V5 and V4 contracts. Specify your desired version in your project's package.json:

"resolutions": {
"@openzeppelin/contracts": "^5.0.1",
}

LayerZero also provides create-lz-oapp, an npx package that allows developers to create any omnichain application in <4 minutes!

tip

Get started by running the following from your command line:

npx create-lz-oapp@latest

Usage

Once installed, you can use the contracts in the library by importing them:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;

import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { OApp } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/OApp.sol";


contract MyOApp is OApp {
constructor(address _endpoint, address _owner) OApp(_endpoint, _owner) Ownable(_owner) {}

// ... rest of OApp interface functions
}

To keep your system secure, you should always use the installed code as-is, and neither copy-paste it from online sources, nor modify it directly.

Most of the LayerZero contracts are expected to be used via inheritance: you will inherit from them when writing your own contracts.

Tooling

LayerZero also provides developer tooling to simplify the contract creation, testing, and deployment process:

  • LayerZero Scan: a comprehensive block explorer, search, API, and analytics platform for tracking and debugging your omnichain transactions.

  • TestHelper (Foundry): a suite of functions to simulate cross-chain transactions and validate the behavior of OApps locally in your Foundry unit tests.

You can also ask for help or follow development in the Discord.