Skip to content
Lattice

ERC20Crosschain

Git Source

Inherits: IBridgeFungible, IERC7786MessageHandler

Title: ERC20Crosschain

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

(https://github.com/OpenZeppelin/openzeppelin-contracts/blob/5fd1781b1454fd1ef8e722282f86f9293cacf256/contracts/token/ERC20/extensions/ERC20Crosschain.sol)

Self-bridging ERC-20 extension facet: crosschainTransfer burns the token's own supply and sends a message; an inbound message mints it on the destination. Mount alongside ERC20 + CrosschainLink; register under FUNGIBLE_BRIDGE_TAG. No separate bridge or external token.

Stateless delegator — logic in ERC20CrosschainLib, balances reuse the ERC20 storage. processMessage is callable only via the Diamond's own receiveMessage dispatch (msg.sender == address(this)). Payload format matches BridgeFungible (interop-compatible).

Note:

  • lattice-version: 0.1.0

Functions

crosschainTransfer

Bridge amount of the configured token to a crosschain recipient.

function crosschainTransfer(bytes calldata to, uint256 amount) external virtual override 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.

processMessage

Process a validated, de-duplicated cross-chain message.

function processMessage(
        bytes32 receiveId,
        bytes calldata,
        /*sender*/
        bytes calldata payload
    )
        external
        virtual
        override;

Parameters

NameTypeDescription
receiveIdbytes32The gateway-assigned unique message id (already checked for replay by the facet).
_bytesThe ERC-7930 interoperable address of the source (includes the source chain).
payloadbytesThe message payload with the leading 4-byte handler tag stripped.

exportSelectors

ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).

Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches forge inspect ERC20Crosschain methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: crosschainTransfer(bytes,uint256) 0x28dcc8d8 processMessage(bytes32,bytes,bytes) 0x902d5027

function exportSelectors() external pure virtual returns (bytes memory selectors);

Returns

NameTypeDescription
selectorsbytes