BridgeERC20Lib
Title: BridgeERC20Lib
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Adapted for EIP-2535 from OpenZeppelin BridgeERC20 v5.6.1 (https://github.com/OpenZeppelin/openzeppelin-contracts).
Custody bridge for legacy ERC-20s: locks tokens on send, releases them on receive. Acts as an IERC7786MessageHandler co-mounted with a CrosschainLink facet.
Functions
bridgeERC20Storage
function bridgeERC20Storage() internal pure returns (BridgeERC20Storage storage $);Returns
| Name | Type | Description |
|---|---|---|
| $ | BridgeERC20Storage |
__BridgeERC20_init
Configures the bridged token and registers the IBridgeFungible ERC-165 interface.
function __BridgeERC20_init(address token_) internal;Parameters
| Name | Type | Description |
|---|---|---|
| token_ | address |
token
The bridged ERC-20 token.
function token() internal view returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
crosschainTransfer
Locks amount of the token in custody and sends a bridge message to the destination chain.
function crosschainTransfer(bytes calldata to, uint256 amount) internal 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 here and release on the destination. |
Returns
| Name | Type | Description |
|---|---|---|
| sendId | bytes32 |
processMessage
Releases custodied tokens to the inbound recipient. Callable only via the Diamond's own
authenticated receiveMessage dispatch (msg.sender == address(this)).
function processMessage(bytes32 receiveId, bytes calldata payload) internal;Parameters
| Name | Type | Description |
|---|---|---|
| receiveId | bytes32 | The de-duplicated message id (replay already checked by CrosschainLink). |
| payload | bytes | The tag-stripped inbound payload abi.encode(from, toAddrBytes, amount). |