LayerZero Endpoint Alt
The LayerZero Endpoint Alt is a variant of the LayerZero Endpoint designed for chains where a fungible token standard (rather than the chain's native gas token) serves as the currency for LayerZero fee payments.
While the standard Endpoint processes fees via the chain's native token, Endpoint Alt accepts fees through token transfers using the chain's fungible token standard. This enables LayerZero to support chains where the native gas token has no economic value or where a different token is used as the primary currency.
EVM Implementation
On EVM chains, the Endpoint Alt implementation (EndpointV2Alt) uses ERC20 tokens for fee payments instead of native ETH/gas tokens sent via msg.value.
Key Differences from Standard Endpoint
Endpoint Alt inherits all core functionality from the standard LayerZero Endpoint - including message channel management, library configuration, reentrancy protection, and message composition - but overrides the fee payment mechanism.
| Aspect | Standard Endpoint | Endpoint Alt |
|---|---|---|
| Fee Payment | Chain's native gas token | Fungible token standard (e.g., ERC20) |
| Fee Token Discovery | Implicit (native token) | Query endpoint for configured token address |
| Prerequisites | None | Must approve Endpoint to spend fee tokens |
Fee Payment Flow
The following diagrams illustrate the fee payment flow differences on EVM chains.
Standard Endpoint Flow
Endpoint Alt Flow
Modified Functions (EVM)
On EVM chains, EndpointV2Alt overrides the following functions from the base EndpointV2 contract:
| Function | Description |
|---|---|
constructor | Accepts an additional _altToken parameter specifying the ERC20 fee token address, stored as an immutable variable for gas optimization. |
_payNative | Reverts if msg.value > 0 (with LZ_OnlyAltToken), then delegates to _payToken() for ERC20 transfers instead of native token transfers. |
_suppliedNative | Returns IERC20(nativeErc20).balanceOf(address(this)) instead of msg.value, checking the contract's ERC20 balance. |
setLzToken | Adds validation to prevent setting lzToken to the same address as nativeErc20, avoiding accounting conflicts between the two fee payment systems. |
nativeToken | Returns the configured nativeErc20 address instead of address(0), allowing callers to discover the required fee token. |
Integration Notes
When building on a chain that uses Endpoint Alt:
| Consideration | Description |
|---|---|
| Discover the fee token | Query the Endpoint to retrieve the required fee token address. |
| Approve before sending | Your contract must authorize the Endpoint to spend fee tokens before sending messages. |
| Quote fees correctly | The quote() function returns the required fee amount in the configured fee token, not native currency. |
EVM-Specific Notes
| Consideration | Description |
|---|---|
Call nativeToken() | Returns the ERC20 address used for fees; returns address(0) on standard endpoints. |
| Never send msg.value | Any transaction with msg.value > 0 will revert with LZ_OnlyAltToken. |
| Use OFT Alt for tokens | When deploying OFTs on Endpoint Alt chains, use the OFT Alt contract variants. |
Checking Endpoint Type (EVM)
To determine whether an EVM chain uses the standard Endpoint or Endpoint Alt:
address feeToken = ILayerZeroEndpointV2(endpoint).nativeToken();
if (feeToken == address(0)) {
// Standard Endpoint: pay fees with native token (msg.value)
} else {
// Endpoint Alt: pay fees with ERC20 at feeToken address
}
Summary
Endpoint Alt extends the standard LayerZero Endpoint to support chains where a fungible token standard replaces the native gas token for fee payments. On EVM chains, this means using ERC20 tokens instead of native ETH/gas tokens. All other protocol guarantees - immutability, permissionless messaging, channel security, and exactly-once delivery - remain unchanged.
Further Reading
- LayerZero Endpoint - Core Endpoint architecture and modules
- OFT Alt - Building OFTs on chains with Endpoint Alt