ERC20Crosschain
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)
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
| Name | Type | Description |
|---|---|---|
| to | bytes | The full ERC-7930 interoperable address of the recipient (chain ref + address). |
| amount | uint256 | The amount to lock/burn here and release/mint on the destination chain. |
Returns
| Name | Type | Description |
|---|---|---|
| sendId | bytes32 | The 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
| Name | Type | Description |
|---|---|---|
| receiveId | bytes32 | The gateway-assigned unique message id (already checked for replay by the facet). |
| _ | bytes | The ERC-7930 interoperable address of the source (includes the source chain). |
| payload | bytes | The 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
| Name | Type | Description |
|---|---|---|
| selectors | bytes |