> ## Documentation Index
> Fetch the complete documentation index at: https://docs.layerzero.network/llms.txt
> Use this file to discover all available pages before exploring further.

# 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...

The LayerZero Endpoint Alt is a variant of the [LayerZero Endpoint](./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](./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

```mermaid wrap theme={null}
sequenceDiagram
participant OApp
participant Endpoint
participant MessageLib as Message Library

    OApp->>Endpoint: send{value: fee}(params, refundAddress)
    Endpoint->>Endpoint: Calculate required fees
    Endpoint->>MessageLib: Transfer native token fee
    Endpoint->>OApp: Refund excess native token
```

### Endpoint Alt Flow

```mermaid wrap theme={null}
sequenceDiagram
participant OApp
participant Endpoint as Endpoint Alt
participant MessageLib as Message Library

    OApp->>Endpoint: approve(endpoint, amount)
    OApp->>Endpoint: Transfer ERC20 tokens
    OApp->>Endpoint: send(params, refundAddress)
    Note right of OApp: No msg.value allowed
    Endpoint->>Endpoint: Calculate required fees
    Endpoint->>MessageLib: Transfer ERC20 fee
    Endpoint->>OApp: Refund excess ERC20
```

## 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](/v2/developers/evm/oft/quickstart#oft-alt) contract variants. |

## Checking Endpoint Type (EVM)

To determine whether an EVM chain uses the standard Endpoint or Endpoint Alt:

```solidity wrap theme={null}
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](./message-security), and exactly-once delivery - remain unchanged.

## Further Reading

* [LayerZero Endpoint](./layerzero-endpoint) - Core Endpoint architecture and modules
* [OFT Alt](/v2/developers/evm/oft/quickstart#oft-alt) - Building OFTs on chains with Endpoint Alt
