Contracts
LayerZero enable seamless cross-chain messaging, configurations for security, and other quality of life improvements to simplify cross-chain development:
Contract Standards
Send arbitrary data and external function calls (OApp)
Create and send new Omnichain Fungible Tokens (OFT)
Adapt deployed ERC-20 tokens to the OFT Standard (OFT Adapter)
Execute new composable contract logic after receiving a message (
lzCompose
)
Protocol Configurations
Configure which decentralized verifier networks secure your messages (Security Stack)
Configure who executes your messages on the destination chain (Executor)
Abstract away the destination chain's gas and fund each message (Execution Options)
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
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!
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 "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/OApp.sol";
contract MyOApp is OApp {
constructor(address _endpoint, address _owner) OApp(_endpoint, _owner) {}
}
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.