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.
LayerZero Solidity Contract Standards
LayerZero Solidity Protocol Configurations
To find all of LayerZero's contracts visit the LayerZero V2 Protocol Repo.
Installation
To start sending cross-chain messages with LayerZero, you can find install instructions for each contract package in OApp Quickstart, OFT Quickstart, or ONFT Quickstart.
LayerZero also provides create-lz-oapp, an all-in-one npx package that allows developers to create a project from any of the available omnichain standards in <4 minutes!
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/oapp-evm/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.