Cross-chain / Bridge·EVM · Solana · Aptos · Multi-chain
LayerZero
Omnichain messaging protocol. V2 OApp/OFT standards let contracts send arbitrary messages and tokens across 90+ chains with configurable security stacks (DVNs).
- 01omnichain dApps
- 02cross-chain token (OFT) deployments
- 03cross-chain governance / state sync
- 04custom DVN security configurations
- 05omnichain NFTs (ONFT)
- pnpm add @layerzerolabs/oapp-evm @layerzerolabs/oft-evm @layerzerolabs/lz-evm-protocol-v2 @layerzerolabs/devtools-evm-hardhat
- npx create-lz-oapp@latest
| Variable | Scope | Description |
|---|---|---|
| LAYERZERO_API_KEY | Server | Optional LayerZero Scan / API key for elevated indexer rate limits when polling message status. |
| PRIVATE_KEY | Server | Deployer private key for `hardhat lz:deploy` and `lz:oapp:wire` tasks across chains. |
Bootstrap with `npx create-lz-oapp@latest` to scaffold a V2 OApp/OFT project. Inherit `OApp` (or `OFT`) and use `_lzSend(dstEid, message, options, fee, refundAddress)` to send and `_lzReceive(origin, guid, message, executor, extraData)` to handle inbound. Quote fees with `endpoint.quote` before sending. Use the `@layerzerolabs/devtools-evm-hardhat` `lz:oapp:wire` task and a `layerzero.config.ts` to set peers, enforced options, send/receive libraries, and DVNs per pathway. Track delivery via LayerZero Scan (`https://layerzeroscan.com/tx/<hash>`).
- ⚑DVN configuration is per-pathway and per-direction — forgetting `setReceiveLibrary`/required DVNs leaves messages stuck or executable by the default stack you didn't intend.
- ⚑`_lzSend` reverts if the quoted native fee is insufficient; always re-quote immediately before sending and forward `msg.value` exactly.
- ⚑Endpoint IDs (EIDs) are NOT EVM chain IDs — use the LayerZero EID table; mixing them is a top-3 bug.
- ⚑Enforced options must be set on the OApp or executor will not deliver — destination gas defaults are deliberately low.
- ⚑Solana and Aptos OApp toolchains are separate packages with their own deployment flow — V2 EVM patterns don't translate 1:1.
- ⚑Bridging between testnets and mainnets is impossible by design; ensure `peer` is wired only between matching environments.