This ERC introduces a minimal interface for tokens to communicate cross-chain. It allows bridges with mint and burn rights to send and relay token transfers with a standardized API.
The interface is bridge agnostic and fully extensible.
PR:
This ERC introduces a minimal interface for tokens to communicate cross-chain. It allows bridges with mint and burn rights to send and relay token transfers with a standardized API.
The interface is bridge agnostic and fully extensible.
PR:
I welcome the minimalism.
Yet, how do you expect the compatibility with xERC20? ( ERC 7281 ) - would be nice to have that elaborated in the compatibility section.
+1 to @radek s question.
Hi @drgorilla.eth, I like the ERC design as it is pretty minimal!
Weâve been working on ERC-7786 (crosschain messaging gateways) to define a minimal standard to simply âget a message to another chainâ. I tried to implement ERC-7802 on top of ERC-7786. Hereâs the code (WIP). Weâre planning to include it in the community version of OpenZeppelin Contracts
The idea to combine these 2 standards is because ERC-7802 defines an interface where a bridge address can mint or burn, but I would argue that it would be better if ERC-7802 depends on ERC-7786 to make the crosschain token its messaging gateway. This way, the bridge integration is abstracted away and the ERC20 can expose a crosschainTransfer
that burns tokens on the source chain and relays a mint instruction to the destination chain.
EDIT: Iâm rethinking the crosschainTransfer
idea since I see the reasoning behind offloading the logic from the token. Still, we appreciate feedback, weâre planning to put this into the library pretty soon
They complement each other. ERC-7802 defines the minimal interface for an ERC-20 token to communicate cross-chain, but it doesnât specify how a protocol should send a cross-chain message to communicate with such tokens. Similarly, it doesnât specify how a user will transfer tokens on-chain.
I agree this standard should remain minimal, but I would agree it may benefit if they specify an optional interface for the âtoken bridgeâ that depends on ERC-7786. It also makes sense to put it in another ERC.
Regarding compatibility with xERC20 (ERC-7802), I wrote this document:
Can it be an issue that an adapter for xERC20 doesnât emit CrosschainMint/Burn? This is not discussed in the document, but these events are specified as âMUSTâ. If these events wont be reliable, it might make sense to lower the requirement in the spec (SHOULD or MAY) or even remove it.
The adapter itself is not an implementation of the IERC7802
standard, nor is it an ERC20 token. Instead, it serves as an intermediary to enable a bridgeâalready compliant with the IERC7802
APIâto interact with xERC20 tokens that may not natively implement this interface.
Since the adapter is merely a compatibility layer and not a token contract, it is not required to emit CrosschainMint
or CrosschainBurn
events. These events are only mandatory for contracts that directly implement IERC7802
. The role of the adapter is to translate standardized bridge calls into the xERC20âs existing mint
and burn
functionality, ensuring operational compatibility.
Love the proposal! There is definitely a problem with bridges as every provider forces to use their own mint/burn
interface.
Have several questions though:
Maybe it is worth expanding the crosschainMint()
and crosschainBurn()
interfaces to accept an additional bytes
parameter?
So the new function signatures will be:
function crosschainMint(address _account, uint256 _amount, bytes memory _payload);
function crosschainBurn(address _account, uint256 _amount, bytes memory _payload);
Possibly this can allow ERC-7802 tokens to perform some business-specific logic.
In the provided reference implementation, shouldnât there be token allowance spending in the crosschainBurn()
function?
function crosschainBurn(address _from, uint256 _amount) external onlyTokenBridge {
_spendAllowance(_from, msg.sender, _amount); // <-- add this line
_burn(_from, _amount);
emit CrosschainBurn(_from, _amount, msg.sender);
}
It is probably fine the way it is implemented now provided the TokenBridge
understands current behavior and prohibits grefing.
Great points!
_spendAllowance
would be more consistent with systems like xERC20, where allowances are essential. However, for this minimal approach, it is not necessary. If needed, allowances can always be added later for specific implementations.I agree with the rational and adding metadata byte param.
Being in the middle of the implementation into ERC20 using both xERC20 and ERC7802.
I believe the mentioned msg.sender
is not correct in the standard:
Events
CrosschainMintMUST trigger when crosschainMint is successfully called. The _sender parameter MUST be set to the msg.sender at the time the function is called.
event CrosschainMint(address indexed _to, uint256 _amount, address indexed _sender);
I assume the rationale to emit sender is to filter out which events are related to the particular bridge.
In the case there is an adapter between the bridge and ERC20 token, such adapter becomes msg.sender.
This is an interesting point. I see the concern about the adapter becoming msg.sender
, but I donât necessarily think itâs an issue for the event to emit the adapterâs address. If we change _sender
, we might introduce inconsistencies or require extra logic to track the original caller. Keeping msg.sender
as-is ensures consistency, and indexers can be designed to trace the adapter path when necessary.
Hi does ERC-7802 has a public audit report so far? Thank you! @drgorilla.eth
FYI - here is the draft of the minimal xERC20 standard: