Skip to main content

Overview

MeltBridge is deployed on each source chain (Ethereum, Arbitrum, etc.). It implements the “Lock” side of the Lock & Mint pattern — locking user tokens and sending LayerZero messages to MeltHub on HyperEVM. Inherits: OApp (LayerZero), Pausable, ReentrancyGuard

Constructor

constructor(address _lzEndpoint, address _owner, uint32 _hyperEvmEid)
ParameterDescription
_lzEndpointLayerZero endpoint on this source chain
_ownerContract owner
_hyperEvmEidLayerZero endpoint ID of HyperEVM (destination)

Bridge In

function bridge(
    address token,
    uint256 amount,
    bytes32 recipient,
    bool toCore
) external payable returns (MessagingReceipt memory)
Bridges tokens from source chain to HyperEVM.
ParameterDescription
tokenERC20 token address to bridge
amountAmount to bridge
recipientRecipient address on HyperEVM (as bytes32)
toCoreIf true, auto-routes to HyperCore after minting
Flow:
  1. Validates token is supported and amount > 0
  2. Transfers tokens from user → locks in contract
  3. Encodes payload and sends via LayerZero
  4. Gas limit: 200k base, 400k if toCore (needs extra gas for HyperCore precompile calls)
Requires msg.value for LayerZero fees. Use quoteBridge first.

quoteBridge

function quoteBridge(
    address token,
    uint256 amount,
    bytes32 recipient,
    bool toCore
) external view returns (MessagingFee memory)
Returns estimated LayerZero fee.

Bridge Back (Receive)

When MeltHub sends a bridge-back message, _lzReceive handles it:
  1. Validates message is from HyperEVM
  2. Decodes: (token, recipient, amount)
  3. Checks token is supported and sufficient locked balance exists
  4. Releases locked tokens to recipient
  5. Emits BridgeCompleted

Admin Functions

FunctionDescription
addToken(address)Add token to supported list
removeToken(address)Remove token from supported list
pause() / unpause()Pause/unpause bridge operations

View Functions

FunctionReturns
isTokenSupported(token)Whether token can be bridged
getLockedBalance(token)Amount of token locked in contract

Events

EventEmitted When
TokenAddedNew token added to supported list
TokenRemovedToken removed from supported list
BridgeInitiatedBridge-in transaction sent
BridgeCompletedBridge-back tokens released