Skip to content
Lattice

IBridgeFungible

Git Source

Title: IBridgeFungible

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Adapted for EIP-2535 from OpenZeppelin BridgeFungible v5.6.1 (https://github.com/OpenZeppelin/openzeppelin-contracts)

(https://github.com/OpenZeppelin/openzeppelin-contracts/blob/5fd1781b1454fd1ef8e722282f86f9293cacf256/contracts/crosschain/bridges/abstract/BridgeFungible.sol)

Shared events, errors, and ABI for the fungible cross-chain bridge facets — BridgeERC20 (custody) and BridgeERC7802 (mint/burn). Both register this interface for ERC-165 discovery; they differ only in their ERC-7201 storage namespace and the lock/unlock token operation, so a given Diamond mounts at most one of them (they share the crosschainTransfer/handler selectors).

Each bridge is an IERC7786MessageHandler registered under a shared fungible-bridge tag on a co-mounted CrosschainLink facet; crosschainTransfer sends through that facet's link registry.

Functions

crosschainTransfer

Bridge amount of the configured token to a crosschain recipient.

function crosschainTransfer(bytes calldata to, uint256 amount) external returns (bytes32 sendId);

Parameters

NameTypeDescription
tobytesThe full ERC-7930 interoperable address of the recipient (chain ref + address).
amountuint256The amount to lock/burn here and release/mint on the destination chain.

Returns

NameTypeDescription
sendIdbytes32The ERC-7786 gateway-assigned send id.

Events

CrosschainFungibleTransferSent

Emitted when a crosschain transfer is sent. to is a full ERC-7930 interoperable address.

event CrosschainFungibleTransferSent(bytes32 indexed sendId, address indexed from, bytes to, uint256 amount);

Parameters

NameTypeDescription
sendIdbytes32
fromaddress
tobytes
amountuint256

CrosschainFungibleTransferReceived

Emitted when an inbound crosschain transfer is credited to to on this chain.

event CrosschainFungibleTransferReceived(bytes32 indexed receiveId, bytes from, address indexed to, uint256 amount);

Parameters

NameTypeDescription
receiveIdbytes32
frombytes
toaddress
amountuint256

Errors

BridgeZeroToken

The bridged token configured at init was the zero address.

error BridgeZeroToken();

BridgeTransferFailed

An ERC-20 transfer/transferFrom failed: it reverted, returned non-true, or token has no code.

error BridgeTransferFailed(address token);

Parameters

NameTypeDescription
tokenaddress

BridgeInvalidRecipient

The inbound destination address was not a 20-byte EVM address.

error BridgeInvalidRecipient();

BridgeUnauthorizedCaller

processMessage was called by something other than the Diamond's own authenticated receiveMessage dispatch (i.e. msg.sender != address(this)).

error BridgeUnauthorizedCaller(address caller);

Parameters

NameTypeDescription
calleraddress

BridgeAmountMismatch

A locked-custody transferFrom credited an amount other than requested (fee-on-transfer tokens are unsupported: locking less than is minted on the destination breaks 1:1).

error BridgeAmountMismatch(uint256 requested, uint256 received);

Parameters

NameTypeDescription
requesteduint256
receiveduint256