Skip to content
Lattice

BridgeERC7802Lib

Git Source

Title: BridgeERC7802Lib

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

Mint/burn bridge for ERC-7802 tokens (approval-free): burns on send, mints on receive. Acts as an IERC7786MessageHandler co-mounted with a CrosschainLink facet.

Functions

bridgeERC7802Storage

function bridgeERC7802Storage() internal pure returns (BridgeERC7802Storage storage $);

Returns

NameTypeDescription
$BridgeERC7802Storage

__BridgeERC7802_init

Configures the bridged token and registers the IBridgeFungible ERC-165 interface.

function __BridgeERC7802_init(address token_) internal;

Parameters

NameTypeDescription
token_address

token

The bridged ERC-7802 token.

function token() internal view returns (address);

Returns

NameTypeDescription
<none>address

crosschainTransfer

Burns amount from the caller (ERC-7802) and sends a bridge message to the destination.

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

Parameters

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

Returns

NameTypeDescription
sendIdbytes32

processMessage

Mints tokens to the inbound recipient (ERC-7802). Callable only via the Diamond's own authenticated receiveMessage dispatch (msg.sender == address(this)).

function processMessage(bytes32 receiveId, bytes calldata payload) internal;

Parameters

NameTypeDescription
receiveIdbytes32The de-duplicated message id (replay already checked by CrosschainLink).
payloadbytesThe tag-stripped inbound payload abi.encode(from, toAddrBytes, amount).