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
| Parameter | Description |
|---|---|
_lzEndpoint | LayerZero endpoint on this source chain |
_owner | Contract owner |
_hyperEvmEid | LayerZero endpoint ID of HyperEVM (destination) |
Bridge In
| Parameter | Description |
|---|---|
token | ERC20 token address to bridge |
amount | Amount to bridge |
recipient | Recipient address on HyperEVM (as bytes32) |
toCore | If true, auto-routes to HyperCore after minting |
- Validates token is supported and amount > 0
- Transfers tokens from user → locks in contract
- Encodes payload and sends via LayerZero
- Gas limit: 200k base, 400k if
toCore(needs extra gas for HyperCore precompile calls)
msg.value for LayerZero fees. Use quoteBridge first.
quoteBridge
Bridge Back (Receive)
WhenMeltHub sends a bridge-back message, _lzReceive handles it:
- Validates message is from HyperEVM
- Decodes:
(token, recipient, amount) - Checks token is supported and sufficient locked balance exists
- Releases locked tokens to recipient
- Emits
BridgeCompleted
Admin Functions
| Function | Description |
|---|---|
addToken(address) | Add token to supported list |
removeToken(address) | Remove token from supported list |
pause() / unpause() | Pause/unpause bridge operations |
View Functions
| Function | Returns |
|---|---|
isTokenSupported(token) | Whether token can be bridged |
getLockedBalance(token) | Amount of token locked in contract |
Events
| Event | Emitted When |
|---|---|
TokenAdded | New token added to supported list |
TokenRemoved | Token removed from supported list |
BridgeInitiated | Bridge-in transaction sent |
BridgeCompleted | Bridge-back tokens released |
