From 40b7b01391f7a78ac96667f645b553102db24e56 Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Wed, 30 Oct 2024 14:58:03 -0300 Subject: [PATCH 01/26] Add ERC: Crosschain Token Interface --- ERCS/erc-draft-crosschain-token-interface.md | 174 +++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 ERCS/erc-draft-crosschain-token-interface.md diff --git a/ERCS/erc-draft-crosschain-token-interface.md b/ERCS/erc-draft-crosschain-token-interface.md new file mode 100644 index 00000000000..9f9a6e2af56 --- /dev/null +++ b/ERCS/erc-draft-crosschain-token-interface.md @@ -0,0 +1,174 @@ +--- +eip: +title: Crosschain Token Interface +description: Minimal token interface for cross-chain transfers +status: Draft +type: Standards Track +authors: Wonderland (skeletor , parti , Joxes , ng , agus duha , 0x Discotech <0xdiscotech@defi.sucks>, gotzen lenek ), Uniswap (0age <0age@uniswap.org>), OP Labs (Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian ) +created: 2024-10-30 +--- + +## Abstract + +The ERC-xxx standard 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. + +## Motivation + +All rollups and multiple important sidechains (Gnosis and Polygon PoS, among others) implement canonical bridges that embed their security into some part of the network's core architecture. These bridges do not have mint/burn rights over original tokens, so they usually lock (unlock) liquidity on the native chain and then mint (burn) a non-equivalent representation on the other. Mint/burn is used because the native token is non-existent on that side, so they must create a new representation. + +However, each bridge implements a different interface for minting/burning on non-native chains. For example, L1 bridged tokens need to support the `OptimismMintableERC20` specification when bridged (minted) to the OP Stack, but the `IArbToken` interface when bridged to the Arbitrum Stack. + +This interface fragmentation is a massive issue in cross-chain communication among chains via third-party bridges or future canonical solutions. At this point, it is clear that every bridge would benefit from a standardized interface for minted/burnt tokens. + +There have been different attempts in the past to standardize token-bridging interfaces. The most relevant proposal has been ERC-7281. However, third-party providers are also developing cross-chain token frameworks, such as NTT by Wormhole and OFT by LayerZero. Each framework defines its features, like rate limits and fee switches, and implements its mint and burn versions. The resultant interfaces become highly specific, lacking naming conventions and structures. + +The proposed interface includes the most relevant and minimal set of actions used by most of these standards. These actions also do not require any governance or owner participation, in contrast, for instance, to set rate limits. xERC20, OFT, NTT, and others can be built on top of this interface. + +## Specifications + +This ERC introduces the `IERCxxx` interface. + +### Methods + +**`crosschainMint`** + +Mints `_amount` of token to address `_account`. + +This function works as the minting entry point for bridge contracts. Each implementation is responsible for its access control logic. + +```solidity +crosschainMint(address _account, uint256 _amount) +``` + +**`crosschainBurn`** + +Burns `_amount` of token from address `_account`. + +This function works as the burning entry point for bridge contracts. Each implementation is responsible for its access control logic. + +```solidity +crosschainBurn(address _account, uint256 _amount) +``` + +### Events + +**`CrosschainMint`** + +MUST trigger when `crosschainMint` is successfully called. + +```solidity +event CrosschainMint(address indexed _to, uint256 _amount) +``` + +Note: implementations might consider additionally emitting `Transfer(address(0), _to, _amount)`to be compliant with [ERC-5679](erc-5679.md). + +**`CrosschainBurnt`** + +MUST trigger when `crosschainBurn` is successfully called. + +```solidity +event CrosschainBurnt(address indexed _from, uint256 _amount) +``` + +Note: implementations might consider additionally emitting `Transfer(_from, address(0), _amount)` to be compliant with [ERC-5679](erc-5679.md). + +## Rationale + +The core design decisions behind this minimal interface are + +- Bridge agnosticism. +- Extensibility. + +**Bridge agnosticism** +This interface is designed so bridges, not tokens, contain the logic to process cross-chain actions. By maintaining this separation of concerns, token contracts remain simple, reducing their attack surface and easing auditing and upgradability. Offloading cross-chain complexities to bridge contracts ensures that tokens do not embed specific bridge logic. + +By implementing the proposed interface, tokens can be supported by different bridge designs: + +- Lock/unlock bridges can still operate and do not require any token modification. +- Burn/mint bridges can now use a universal and minimal token interface, so they will not need to introduce bridge-specific representations, improving cross-chain fungibility. + +**Extensibility** +The minimal interface serves as a foundational layer upon which other standards can be built. +Token issuers or bridge contracts can extend functionality by adding features such as mint/burn limits, cross-chain transfer fees, and more without altering the core interface. + +The interface is intentionally neutral and does not impose conditions on: + +- **Access Control**: Token issuers determine who is authorized to call `crosschainMint()` and `crosschainBurn()`. +- **Zero Amount Calls**: Token issuers decide whether to allow or revert calls with zero amounts. + +## Backwards Compatibility + +This proposal is fully backwards compatible with [ERC-20](erc-20.md). + +As discussed in the Motivation section, a minimal, flexible cross-chain standard interface is necessary. The problem becomes larger as more tokens are deployed without a standardized format. + +- Upgradable tokens can be upgraded to implement the new interface. +- Non-upgradable tokens cannot implement the interface on the token itself. They can still migrate to a standard-compliant version using a lockbox mechanism, as proposed by ERC-7281. The idea is to lock non-mintable tokens and mint the same amount of interface-compliant tokens. The bridge contract can act as a lockbox on the native chain. + +Bridge contracts will also need an upgrade to integrate with the interface. Most popular bridges in terms of liquidity at the date are upgradable or use tokens that can be upgraded to point to new bridge contracts. + +1. Arbitrum One ($5.23B) +2. Portal Wormhole ($2.43B) +3. Polygon PoS ($2.15B) +4. OP Mainnet ($2.09B) +5. Mantle ($983M) +6. LayerZero OFTs ($465M) +7. Omnibridge ($449M) +8. Base ($350M) +9. Scroll ($128M) +10. zkSync ($77M) + +Source: L2Beat (10/31/24) + +## Reference Implementation + +```solidity +// SPDX-License-Identifier: MIT +pragma solidity 0.8.25; + +abstract contract CrosschainERC20 is ERC20, IERCxxx { + /// @notice Address of the TOKEN_BRIDGE contract that is allowed to mint/burn tokens. + address public immutable TOKEN_BRIDGE; + + /// @notice Constructor to set the TOKEN_BRIDGE address. + /// @param _tokenBridge Address of the TOKEN_BRIDGE. + constructor(address _tokenBridge) { + require(_tokenBridge != address(0), "Invalid TOKEN_BRIDGE address"); + TOKEN_BRIDGE = _tokenBridge; + } + + /// @notice A modifier that only allows the TOKEN_BRIDGE to call + modifier onlyTokenBridge() { + if (msg.sender != TOKEN_BRIDGE) revert Unauthorized(); + _; + } + + /// @notice Allows the TOKEN_BRIDGE to mint tokens. + /// @param _to Address to mint tokens to. + /// @param _amount Amount of tokens to mint. + function crosschainMint(address _to, uint256 _amount) external onlyTokenBridge { + _mint(_to, _amount); + + emit CrosschainMint(_to, _amount); + } + + /// @notice Allows the TOKEN_BRIDGE to burn tokens. + /// @param _from Address to burn tokens from. + /// @param _amount Amount of tokens to burn. + function crosschainBurn(address _from, uint256 _amount) external onlyTokenBridge { + _burn(_from, _amount); + + emit CrosschainBurn(_from, _amount); + } +} +``` + +## Security Considerations + +Token issuers are responsible for controlling which contracts are authorized to call the `crosschainMint()` and `crosschainBurn()` functions. A buggy or malicious authorized caller could mint or burn tokens improperly, damaging token holders and disrupting integrations. + +One method to minimize potential losses is introducing mint/burn limits, as proposed by ERC-7281. These features are fully compatible with the proposed interface. + +## Copyright + +Copyright and related rights waived via [CC0](https://eips.ethereum.org/LICENSE). \ No newline at end of file From 88e4244e2e2239ec670ccecdd83742a05458cb9b Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Wed, 30 Oct 2024 15:13:40 -0300 Subject: [PATCH 02/26] added temporary erc number --- ERCS/{erc-draft-crosschain-token-interface.md => erc-0000.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ERCS/{erc-draft-crosschain-token-interface.md => erc-0000.md} (100%) diff --git a/ERCS/erc-draft-crosschain-token-interface.md b/ERCS/erc-0000.md similarity index 100% rename from ERCS/erc-draft-crosschain-token-interface.md rename to ERCS/erc-0000.md From f5c5140b3107fc35ef6114578f53c460ac7942fe Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Wed, 30 Oct 2024 15:14:49 -0300 Subject: [PATCH 03/26] added temporary erc number in preamble --- ERCS/erc-0000.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERCS/erc-0000.md b/ERCS/erc-0000.md index 9f9a6e2af56..ce906852ed1 100644 --- a/ERCS/erc-0000.md +++ b/ERCS/erc-0000.md @@ -1,5 +1,5 @@ --- -eip: +eip: 0000 title: Crosschain Token Interface description: Minimal token interface for cross-chain transfers status: Draft From 7a22c411304b6013fafb97a719a98ba37f3be17d Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Wed, 30 Oct 2024 15:22:43 -0300 Subject: [PATCH 04/26] chore: fix lint errors --- ERCS/erc-0000.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ERCS/erc-0000.md b/ERCS/erc-0000.md index ce906852ed1..4b3b1c36a9a 100644 --- a/ERCS/erc-0000.md +++ b/ERCS/erc-0000.md @@ -4,7 +4,9 @@ title: Crosschain Token Interface description: Minimal token interface for cross-chain transfers status: Draft type: Standards Track -authors: Wonderland (skeletor , parti , Joxes , ng , agus duha , 0x Discotech <0xdiscotech@defi.sucks>, gotzen lenek ), Uniswap (0age <0age@uniswap.org>), OP Labs (Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian ) +categoty: ERC +author: Wonderland (skeletor , parti , Joxes , ng , agus duha , 0x Discotech <0xdiscotech@defi.sucks>, gotzen lenek ), Uniswap (0age <0age@uniswap.org>), OP Labs (Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian ) +discussions-to: created: 2024-10-30 --- @@ -20,11 +22,11 @@ However, each bridge implements a different interface for minting/burning on non This interface fragmentation is a massive issue in cross-chain communication among chains via third-party bridges or future canonical solutions. At this point, it is clear that every bridge would benefit from a standardized interface for minted/burnt tokens. -There have been different attempts in the past to standardize token-bridging interfaces. The most relevant proposal has been ERC-7281. However, third-party providers are also developing cross-chain token frameworks, such as NTT by Wormhole and OFT by LayerZero. Each framework defines its features, like rate limits and fee switches, and implements its mint and burn versions. The resultant interfaces become highly specific, lacking naming conventions and structures. +There have been different attempts in the past to standardize token-bridging interfaces. However, third-party providers are also developing cross-chain token frameworks, such as NTT by Wormhole and OFT by LayerZero. Each framework defines its features, like rate limits and fee switches, and implements its mint and burn versions. The resultant interfaces become highly specific, lacking naming conventions and structures. -The proposed interface includes the most relevant and minimal set of actions used by most of these standards. These actions also do not require any governance or owner participation, in contrast, for instance, to set rate limits. xERC20, OFT, NTT, and others can be built on top of this interface. +The proposed interface includes the most relevant and minimal set of actions used by most of these standards. These actions also do not require any governance or owner participation, in contrast, for instance, to set rate limits. xERC-20, OFT, NTT, and others can be built on top of this interface. -## Specifications +## Specification This ERC introduces the `IERCxxx` interface. @@ -103,7 +105,7 @@ This proposal is fully backwards compatible with [ERC-20](erc-20.md). As discussed in the Motivation section, a minimal, flexible cross-chain standard interface is necessary. The problem becomes larger as more tokens are deployed without a standardized format. - Upgradable tokens can be upgraded to implement the new interface. -- Non-upgradable tokens cannot implement the interface on the token itself. They can still migrate to a standard-compliant version using a lockbox mechanism, as proposed by ERC-7281. The idea is to lock non-mintable tokens and mint the same amount of interface-compliant tokens. The bridge contract can act as a lockbox on the native chain. +- Non-upgradable tokens cannot implement the interface on the token itself. They can still migrate to a standard-compliant version using a lockbox mechanism, as proposed by xERC-20. The idea is to lock non-mintable tokens and mint the same amount of interface-compliant tokens. The bridge contract can act as a lockbox on the native chain. Bridge contracts will also need an upgrade to integrate with the interface. Most popular bridges in terms of liquidity at the date are upgradable or use tokens that can be upgraded to point to new bridge contracts. @@ -167,8 +169,8 @@ abstract contract CrosschainERC20 is ERC20, IERCxxx { Token issuers are responsible for controlling which contracts are authorized to call the `crosschainMint()` and `crosschainBurn()` functions. A buggy or malicious authorized caller could mint or burn tokens improperly, damaging token holders and disrupting integrations. -One method to minimize potential losses is introducing mint/burn limits, as proposed by ERC-7281. These features are fully compatible with the proposed interface. +One method to minimize potential losses is introducing mint/burn limits, as proposed by xERC-20. These features are fully compatible with the proposed interface. ## Copyright -Copyright and related rights waived via [CC0](https://eips.ethereum.org/LICENSE). \ No newline at end of file +Copyright and related rights waived via [CC0](../LICENSE.md). \ No newline at end of file From f68b1996743000da7935d7aff772f4c353d86772 Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Wed, 30 Oct 2024 15:29:17 -0300 Subject: [PATCH 05/26] chore: fixing lint --- ERCS/erc-0000.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ERCS/erc-0000.md b/ERCS/erc-0000.md index 4b3b1c36a9a..366081c6762 100644 --- a/ERCS/erc-0000.md +++ b/ERCS/erc-0000.md @@ -2,11 +2,11 @@ eip: 0000 title: Crosschain Token Interface description: Minimal token interface for cross-chain transfers +author: skeletor , parti (@0xParticle), joxes , ng , agus duha , disco <0xdiscotech@defi.sucks>, gotzen ), 0age <0age@uniswap.org>, Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian +discussions-to: status: Draft type: Standards Track -categoty: ERC -author: Wonderland (skeletor , parti , Joxes , ng , agus duha , 0x Discotech <0xdiscotech@defi.sucks>, gotzen lenek ), Uniswap (0age <0age@uniswap.org>), OP Labs (Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian ) -discussions-to: +category: ERC created: 2024-10-30 --- From c70b2aa5e91b83a2c15b94f9c36c490316dba995 Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Wed, 30 Oct 2024 16:31:53 -0300 Subject: [PATCH 06/26] feat: added discussion link --- ERCS/erc-0000.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ERCS/erc-0000.md b/ERCS/erc-0000.md index 366081c6762..3a10dbb9768 100644 --- a/ERCS/erc-0000.md +++ b/ERCS/erc-0000.md @@ -2,8 +2,8 @@ eip: 0000 title: Crosschain Token Interface description: Minimal token interface for cross-chain transfers -author: skeletor , parti (@0xParticle), joxes , ng , agus duha , disco <0xdiscotech@defi.sucks>, gotzen ), 0age <0age@uniswap.org>, Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian -discussions-to: +author: skeletor , parti (@0xParticle), joxes , ng , agus duha , disco <0xdiscotech@defi.sucks>, gotzen , 0age <0age@uniswap.org>, Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian +discussions-to: https://ethereum-magicians.org/t/erc-xxxx-crosschain-token-interface/21508 status: Draft type: Standards Track category: ERC From 2aadee37de3266ad71432df9b3849376043256c0 Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Wed, 30 Oct 2024 16:51:12 -0300 Subject: [PATCH 07/26] fix internal links --- ERCS/erc-0000.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ERCS/erc-0000.md b/ERCS/erc-0000.md index 3a10dbb9768..06edaeef7c4 100644 --- a/ERCS/erc-0000.md +++ b/ERCS/erc-0000.md @@ -62,7 +62,7 @@ MUST trigger when `crosschainMint` is successfully called. event CrosschainMint(address indexed _to, uint256 _amount) ``` -Note: implementations might consider additionally emitting `Transfer(address(0), _to, _amount)`to be compliant with [ERC-5679](erc-5679.md). +Note: implementations might consider additionally emitting `Transfer(address(0), _to, _amount)`to be compliant with [ERC-5679](./erc-5679.md). **`CrosschainBurnt`** @@ -72,7 +72,7 @@ MUST trigger when `crosschainBurn` is successfully called. event CrosschainBurnt(address indexed _from, uint256 _amount) ``` -Note: implementations might consider additionally emitting `Transfer(_from, address(0), _amount)` to be compliant with [ERC-5679](erc-5679.md). +Note: implementations might consider additionally emitting `Transfer(_from, address(0), _amount)` to be compliant with [ERC-5679](./erc-5679.md). ## Rationale @@ -100,7 +100,7 @@ The interface is intentionally neutral and does not impose conditions on: ## Backwards Compatibility -This proposal is fully backwards compatible with [ERC-20](erc-20.md). +This proposal is fully backwards compatible with [ERC-20](./erc-20.md). As discussed in the Motivation section, a minimal, flexible cross-chain standard interface is necessary. The problem becomes larger as more tokens are deployed without a standardized format. From 95f4221ea9f3195c5e5a67efe18dbe6a56fe8a9e Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Wed, 30 Oct 2024 17:07:05 -0300 Subject: [PATCH 08/26] fix links --- ERCS/erc-0000.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ERCS/erc-0000.md b/ERCS/erc-0000.md index 06edaeef7c4..6a2d7a5876e 100644 --- a/ERCS/erc-0000.md +++ b/ERCS/erc-0000.md @@ -62,7 +62,7 @@ MUST trigger when `crosschainMint` is successfully called. event CrosschainMint(address indexed _to, uint256 _amount) ``` -Note: implementations might consider additionally emitting `Transfer(address(0), _to, _amount)`to be compliant with [ERC-5679](./erc-5679.md). +Note: implementations might consider additionally emitting `Transfer(address(0), _to, _amount)`to be compliant with [ERC-5679](./eip-5679.md). **`CrosschainBurnt`** @@ -72,7 +72,7 @@ MUST trigger when `crosschainBurn` is successfully called. event CrosschainBurnt(address indexed _from, uint256 _amount) ``` -Note: implementations might consider additionally emitting `Transfer(_from, address(0), _amount)` to be compliant with [ERC-5679](./erc-5679.md). +Note: implementations might consider additionally emitting `Transfer(_from, address(0), _amount)` to be compliant with [ERC-5679](./eip-5679.md). ## Rationale @@ -100,7 +100,7 @@ The interface is intentionally neutral and does not impose conditions on: ## Backwards Compatibility -This proposal is fully backwards compatible with [ERC-20](./erc-20.md). +This proposal is fully backwards compatible with [ERC-20](./eip-20.md). As discussed in the Motivation section, a minimal, flexible cross-chain standard interface is necessary. The problem becomes larger as more tokens are deployed without a standardized format. From 0eb7d1f198c2cbca65640c9421a5c21c6c004042 Mon Sep 17 00:00:00 2001 From: parti <102677731+0xParticle@users.noreply.github.com> Date: Thu, 31 Oct 2024 09:43:29 -0300 Subject: [PATCH 09/26] Apply suggestions from code review Co-authored-by: Andrew B Coathup <28278242+abcoathup@users.noreply.github.com> Co-authored-by: blaine --- ERCS/erc-0000.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ERCS/erc-0000.md b/ERCS/erc-0000.md index 6a2d7a5876e..aab990a9ba1 100644 --- a/ERCS/erc-0000.md +++ b/ERCS/erc-0000.md @@ -1,9 +1,9 @@ --- -eip: 0000 +eip: 7802 title: Crosschain Token Interface description: Minimal token interface for cross-chain transfers author: skeletor , parti (@0xParticle), joxes , ng , agus duha , disco <0xdiscotech@defi.sucks>, gotzen , 0age <0age@uniswap.org>, Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian -discussions-to: https://ethereum-magicians.org/t/erc-xxxx-crosschain-token-interface/21508 +discussions-to: https://ethereum-magicians.org/t/erc-7802-crosschain-token-interface/21508 status: Draft type: Standards Track category: ERC @@ -12,7 +12,7 @@ created: 2024-10-30 ## Abstract -The ERC-xxx standard 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 ERC-7802 standard 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. ## Motivation @@ -28,7 +28,7 @@ The proposed interface includes the most relevant and minimal set of actions use ## Specification -This ERC introduces the `IERCxxx` interface. +This ERC introduces the `IERC7802` interface. ### Methods @@ -39,7 +39,7 @@ Mints `_amount` of token to address `_account`. This function works as the minting entry point for bridge contracts. Each implementation is responsible for its access control logic. ```solidity -crosschainMint(address _account, uint256 _amount) +function crosschainMint(address _account, uint256 _amount) external; ``` **`crosschainBurn`** @@ -49,7 +49,7 @@ Burns `_amount` of token from address `_account`. This function works as the burning entry point for bridge contracts. Each implementation is responsible for its access control logic. ```solidity -crosschainBurn(address _account, uint256 _amount) +function crosschainBurn(address _account, uint256 _amount) external; ``` ### Events @@ -62,14 +62,14 @@ MUST trigger when `crosschainMint` is successfully called. event CrosschainMint(address indexed _to, uint256 _amount) ``` -Note: implementations might consider additionally emitting `Transfer(address(0), _to, _amount)`to be compliant with [ERC-5679](./eip-5679.md). +Note: implementations might consider additionally emitting `Transfer(address(0), _to, _amount)` to be compliant with [ERC-5679](./eip-5679.md). -**`CrosschainBurnt`** +**`CrosschainBurn`** MUST trigger when `crosschainBurn` is successfully called. ```solidity -event CrosschainBurnt(address indexed _from, uint256 _amount) +event CrosschainBurn(address indexed _from, uint256 _amount) ``` Note: implementations might consider additionally emitting `Transfer(_from, address(0), _amount)` to be compliant with [ERC-5679](./eip-5679.md). @@ -128,7 +128,7 @@ Source: L2Beat (10/31/24) // SPDX-License-Identifier: MIT pragma solidity 0.8.25; -abstract contract CrosschainERC20 is ERC20, IERCxxx { +abstract contract CrosschainERC20 is ERC20, IERC7802 { /// @notice Address of the TOKEN_BRIDGE contract that is allowed to mint/burn tokens. address public immutable TOKEN_BRIDGE; From 2edb93266c826284e0fbaf903640f34b0e77e993 Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Thu, 31 Oct 2024 09:50:18 -0300 Subject: [PATCH 10/26] feat: improved reference code, change authors handles --- ERCS/{erc-0000.md => erc-7802.md} | 39 ++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 6 deletions(-) rename ERCS/{erc-0000.md => erc-7802.md} (81%) diff --git a/ERCS/erc-0000.md b/ERCS/erc-7802.md similarity index 81% rename from ERCS/erc-0000.md rename to ERCS/erc-7802.md index aab990a9ba1..e1c4ada1fd0 100644 --- a/ERCS/erc-0000.md +++ b/ERCS/erc-7802.md @@ -2,7 +2,7 @@ eip: 7802 title: Crosschain Token Interface description: Minimal token interface for cross-chain transfers -author: skeletor , parti (@0xParticle), joxes , ng , agus duha , disco <0xdiscotech@defi.sucks>, gotzen , 0age <0age@uniswap.org>, Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian +author: skeletor (@skeletor-spaceman), parti (@0xParticle), joxes (@Joxess), ng (@0xng), agus duha (@agusduha), disco (@0xDiscotech), gotzen , 0age <0age@uniswap.org>, Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian discussions-to: https://ethereum-magicians.org/t/erc-7802-crosschain-token-interface/21508 status: Draft type: Standards Track @@ -12,7 +12,7 @@ created: 2024-10-30 ## Abstract -The ERC-7802 standard 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. +This standard 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. ## Motivation @@ -128,17 +128,46 @@ Source: L2Beat (10/31/24) // SPDX-License-Identifier: MIT pragma solidity 0.8.25; +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +/// @title IERC7802 +/// @notice Defines the interface for crosschain ERC20 transfers. +interface IERC7802 { + /// @notice Emitted when a crosschain transfer mints tokens. + /// @param to Address of the account tokens are being minted for. + /// @param amount Amount of tokens minted. + event CrosschainMint(address indexed to, uint256 amount); + + /// @notice Emitted when a crosschain transfer burns tokens. + /// @param from Address of the account tokens are being burned from. + /// @param amount Amount of tokens burned. + event CrosschainBurn(address indexed from, uint256 amount); + + /// @notice Mint tokens through a crosschain transfer. + /// @param _to Address to mint tokens to. + /// @param _amount Amount of tokens to mint. + function crosschainMint(address _to, uint256 _amount) external; + + /// @notice Burn tokens through a crosschain transfer. + /// @param _from Address to burn tokens from. + /// @param _amount Amount of tokens to burn. + function crosschainBurn(address _from, uint256 _amount) external; +} + abstract contract CrosschainERC20 is ERC20, IERC7802 { - /// @notice Address of the TOKEN_BRIDGE contract that is allowed to mint/burn tokens. + /// @notice Address of the TOKEN_BRIDGE contract that is allowed to mint/burn tokens. address public immutable TOKEN_BRIDGE; + /// @notice Custom error for unauthorized access. + error Unauthorized(); + /// @notice Constructor to set the TOKEN_BRIDGE address. /// @param _tokenBridge Address of the TOKEN_BRIDGE. constructor(address _tokenBridge) { require(_tokenBridge != address(0), "Invalid TOKEN_BRIDGE address"); TOKEN_BRIDGE = _tokenBridge; } - + /// @notice A modifier that only allows the TOKEN_BRIDGE to call modifier onlyTokenBridge() { if (msg.sender != TOKEN_BRIDGE) revert Unauthorized(); @@ -150,7 +179,6 @@ abstract contract CrosschainERC20 is ERC20, IERC7802 { /// @param _amount Amount of tokens to mint. function crosschainMint(address _to, uint256 _amount) external onlyTokenBridge { _mint(_to, _amount); - emit CrosschainMint(_to, _amount); } @@ -159,7 +187,6 @@ abstract contract CrosschainERC20 is ERC20, IERC7802 { /// @param _amount Amount of tokens to burn. function crosschainBurn(address _from, uint256 _amount) external onlyTokenBridge { _burn(_from, _amount); - emit CrosschainBurn(_from, _amount); } } From a587407a6299bd1f6d2339882fb495672e8f90ed Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Thu, 31 Oct 2024 10:12:58 -0300 Subject: [PATCH 11/26] chore: fix lint --- ERCS/erc-7802.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index e1c4ada1fd0..63f7df90638 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -24,7 +24,7 @@ This interface fragmentation is a massive issue in cross-chain communication amo There have been different attempts in the past to standardize token-bridging interfaces. However, third-party providers are also developing cross-chain token frameworks, such as NTT by Wormhole and OFT by LayerZero. Each framework defines its features, like rate limits and fee switches, and implements its mint and burn versions. The resultant interfaces become highly specific, lacking naming conventions and structures. -The proposed interface includes the most relevant and minimal set of actions used by most of these standards. These actions also do not require any governance or owner participation, in contrast, for instance, to set rate limits. xERC-20, OFT, NTT, and others can be built on top of this interface. +The proposed interface includes the most relevant and minimal set of actions used by most of these standards. These actions also do not require any governance or owner participation, in contrast, for instance, to set rate limits. ## Specification From 0530449bda93b5b001c940ee91f49b58cc1d53fc Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Thu, 31 Oct 2024 14:22:13 -0300 Subject: [PATCH 12/26] feat: added ERC-165 compliance --- ERCS/erc-7802.md | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index 63f7df90638..38a128a23c0 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -2,7 +2,7 @@ eip: 7802 title: Crosschain Token Interface description: Minimal token interface for cross-chain transfers -author: skeletor (@skeletor-spaceman), parti (@0xParticle), joxes (@Joxess), ng (@0xng), agus duha (@agusduha), disco (@0xDiscotech), gotzen , 0age <0age@uniswap.org>, Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian +author: skeletor (@skeletor-spaceman), parti (@0xParticle), joxes (@Joxess), ng (@0xng), agus duha (@agusduha), disco (@0xDiscotech), gotzen , 0age <0age@uniswap.org>, Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian , Blaine Malone <@blmalone> discussions-to: https://ethereum-magicians.org/t/erc-7802-crosschain-token-interface/21508 status: Draft type: Standards Track @@ -30,6 +30,25 @@ The proposed interface includes the most relevant and minimal set of actions use This ERC introduces the `IERC7802` interface. +### Interface Identification + +The interface identifier for `IERC7802` is **`0x33331994`**, calculated according to [ERC-165](./eip-165.md) as the XOR of the function selectors of the two functions in the interface: + +```solidity +bytes4 constant INTERFACE_ID_IERC7802 = + bytes4(keccak256("crosschainMint(address,uint256)")) ^ + bytes4(keccak256("crosschainBurn(address,uint256)")); +``` + +or via Solidity as + +```solidity +type(IERC7802).interfaceId +``` + +Implementors MUST ensure that the `supportsInterface` method of ERC-165 returns true for this interface ID to indicate support for `IERC7802`. + + ### Methods **`crosschainMint`** @@ -98,6 +117,11 @@ The interface is intentionally neutral and does not impose conditions on: - **Access Control**: Token issuers determine who is authorized to call `crosschainMint()` and `crosschainBurn()`. - **Zero Amount Calls**: Token issuers decide whether to allow or revert calls with zero amounts. +### ERC-165 Interface + +The inclusion of ERC-165 provides an additional security check for integrators. By providing the interface identifier through the `supportsInterface` method, callers can programmatically confirm that the token adheres to the `IERC7802` interface. +This verification prevents scenarios where a token might implement only one of the functions, leading to incomplete processing of cross-chain actions. + ## Backwards Compatibility This proposal is fully backwards compatible with [ERC-20](./eip-20.md). @@ -132,7 +156,7 @@ import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; /// @title IERC7802 /// @notice Defines the interface for crosschain ERC20 transfers. -interface IERC7802 { +interface IERC7802 is IERC165 { /// @notice Emitted when a crosschain transfer mints tokens. /// @param to Address of the account tokens are being minted for. /// @param amount Amount of tokens minted. @@ -189,6 +213,10 @@ abstract contract CrosschainERC20 is ERC20, IERC7802 { _burn(_from, _amount); emit CrosschainBurn(_from, _amount); } + + function supportsInterface(bytes4 interfaceId) external pure override returns (bool) { + return interfaceId == type(IERC7802).interfaceId || interfaceId == type(IERC165).interfaceId; + } } ``` From 9ffe3bcfef7b875b39f2e18e52aa43a625611356 Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Thu, 31 Oct 2024 14:24:48 -0300 Subject: [PATCH 13/26] chore: fix preamble --- ERCS/erc-7802.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index 38a128a23c0..bc199f7d932 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -2,7 +2,7 @@ eip: 7802 title: Crosschain Token Interface description: Minimal token interface for cross-chain transfers -author: skeletor (@skeletor-spaceman), parti (@0xParticle), joxes (@Joxess), ng (@0xng), agus duha (@agusduha), disco (@0xDiscotech), gotzen , 0age <0age@uniswap.org>, Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian , Blaine Malone <@blmalone> +author: skeletor (@skeletor-spaceman), parti (@0xParticle), joxes (@Joxess), ng (@0xng), agus duha (@agusduha), disco (@0xDiscotech), gotzen , 0age <0age@uniswap.org>, Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian , Blaine Malone (@blmalone) discussions-to: https://ethereum-magicians.org/t/erc-7802-crosschain-token-interface/21508 status: Draft type: Standards Track From 59e733af7526244949cfa23920d9e5adf880a9ec Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Thu, 31 Oct 2024 15:51:23 -0300 Subject: [PATCH 14/26] feat: added requires field on preamble --- ERCS/erc-7802.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index bc199f7d932..ca3b0ed6495 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -8,6 +8,7 @@ status: Draft type: Standards Track category: ERC created: 2024-10-30 +requires: 165 --- ## Abstract From 1946670f12704cbf3fa2722fe249bb00942e8f53 Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Thu, 31 Oct 2024 16:19:59 -0300 Subject: [PATCH 15/26] feat: improved rationale for erc165 --- ERCS/erc-7802.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index ca3b0ed6495..7e714b27e97 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -121,7 +121,9 @@ The interface is intentionally neutral and does not impose conditions on: ### ERC-165 Interface The inclusion of ERC-165 provides an additional security check for integrators. By providing the interface identifier through the `supportsInterface` method, callers can programmatically confirm that the token adheres to the `IERC7802` interface. -This verification prevents scenarios where a token might implement only one of the functions, leading to incomplete processing of cross-chain actions. +This verification ensures that the token supports both `crosschainMint` and `crosschainBurn` functions, preventing scenarios where only one function is implemented. Such incomplete implementations could lead to issues like users burning tokens to bridge out but being unable to mint them upon return, resulting in failed cross-chain actions. + +It is important to note that this check can only be performed locally on the chain where the token contract resides. There is no inherent guarantee that the token on the receiving chain also supports the IERC7802 interface. Ensuring cross-chain consistency of interface support is the responsibility of the bridge implementation. ## Backwards Compatibility From 6e815b8ebbc45ec06ecd6a9f2b5d5ce5cf79124d Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Thu, 31 Oct 2024 16:30:26 -0300 Subject: [PATCH 16/26] chore: lint --- ERCS/erc-7802.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index 7e714b27e97..428f1552b99 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -123,7 +123,7 @@ The interface is intentionally neutral and does not impose conditions on: The inclusion of ERC-165 provides an additional security check for integrators. By providing the interface identifier through the `supportsInterface` method, callers can programmatically confirm that the token adheres to the `IERC7802` interface. This verification ensures that the token supports both `crosschainMint` and `crosschainBurn` functions, preventing scenarios where only one function is implemented. Such incomplete implementations could lead to issues like users burning tokens to bridge out but being unable to mint them upon return, resulting in failed cross-chain actions. -It is important to note that this check can only be performed locally on the chain where the token contract resides. There is no inherent guarantee that the token on the receiving chain also supports the IERC7802 interface. Ensuring cross-chain consistency of interface support is the responsibility of the bridge implementation. +It is important to note that this check can only be performed locally on the chain where the token contract resides. There is no inherent guarantee that the token on the receiving chain also supports the `IERC7802` interface. Ensuring cross-chain consistency of interface support is the responsibility of the bridge implementation. ## Backwards Compatibility From dae604d993660ab9f7a2000f6d2bbbfdff2fcf89 Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Fri, 1 Nov 2024 12:35:13 -0300 Subject: [PATCH 17/26] feat: improved reference implementation --- ERCS/erc-7802.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index 428f1552b99..f772d6da18c 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -156,6 +156,8 @@ Source: L2Beat (10/31/24) pragma solidity 0.8.25; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; + /// @title IERC7802 /// @notice Defines the interface for crosschain ERC20 transfers. @@ -181,7 +183,7 @@ interface IERC7802 is IERC165 { function crosschainBurn(address _from, uint256 _amount) external; } -abstract contract CrosschainERC20 is ERC20, IERC7802 { +contract CrosschainERC20 is ERC20, IERC7802 { /// @notice Address of the TOKEN_BRIDGE contract that is allowed to mint/burn tokens. address public immutable TOKEN_BRIDGE; @@ -190,7 +192,7 @@ abstract contract CrosschainERC20 is ERC20, IERC7802 { /// @notice Constructor to set the TOKEN_BRIDGE address. /// @param _tokenBridge Address of the TOKEN_BRIDGE. - constructor(address _tokenBridge) { + constructor(address _tokenBridge, string memory name, string memory symbol) ERC20(name, symbol) { require(_tokenBridge != address(0), "Invalid TOKEN_BRIDGE address"); TOKEN_BRIDGE = _tokenBridge; } From b7022c7b3e4978981419cb04967453255f5269c0 Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Mon, 18 Nov 2024 16:12:47 -0300 Subject: [PATCH 18/26] feat: added sender to events --- ERCS/erc-7802.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index f772d6da18c..87d4651600a 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -76,10 +76,11 @@ function crosschainBurn(address _account, uint256 _amount) external; **`CrosschainMint`** -MUST trigger when `crosschainMint` is successfully called. +MUST trigger when `crosschainMint` is successfully called. +The `_sender` parameter MUST be set to the msg.sender at the time the function is called. ```solidity -event CrosschainMint(address indexed _to, uint256 _amount) +event CrosschainMint(address indexed _to, uint256 _amount, address indexed _sender); ``` Note: implementations might consider additionally emitting `Transfer(address(0), _to, _amount)` to be compliant with [ERC-5679](./eip-5679.md). @@ -87,9 +88,10 @@ Note: implementations might consider additionally emitting `Transfer(address(0), **`CrosschainBurn`** MUST trigger when `crosschainBurn` is successfully called. +The `_sender` parameter MUST be set to the msg.sender at the time the function is called. ```solidity -event CrosschainBurn(address indexed _from, uint256 _amount) +event CrosschainBurn(address indexed _from, uint256 _amount, address indexed _sender) ``` Note: implementations might consider additionally emitting `Transfer(_from, address(0), _amount)` to be compliant with [ERC-5679](./eip-5679.md). @@ -165,12 +167,14 @@ interface IERC7802 is IERC165 { /// @notice Emitted when a crosschain transfer mints tokens. /// @param to Address of the account tokens are being minted for. /// @param amount Amount of tokens minted. - event CrosschainMint(address indexed to, uint256 amount); + /// @param sender Address of the caller (msg.sender) who invoked crosschainMint. + event CrosschainMint(address indexed to, uint256 amount, address indexed sender); /// @notice Emitted when a crosschain transfer burns tokens. /// @param from Address of the account tokens are being burned from. /// @param amount Amount of tokens burned. - event CrosschainBurn(address indexed from, uint256 amount); + /// @param sender Address of the caller (msg.sender) who invoked crosschainBurn. + event CrosschainBurn(address indexed from, uint256 amount, address indexed sender); /// @notice Mint tokens through a crosschain transfer. /// @param _to Address to mint tokens to. @@ -208,7 +212,7 @@ contract CrosschainERC20 is ERC20, IERC7802 { /// @param _amount Amount of tokens to mint. function crosschainMint(address _to, uint256 _amount) external onlyTokenBridge { _mint(_to, _amount); - emit CrosschainMint(_to, _amount); + emit CrosschainMint(_to, _amount, msg.sender); } /// @notice Allows the TOKEN_BRIDGE to burn tokens. @@ -216,7 +220,7 @@ contract CrosschainERC20 is ERC20, IERC7802 { /// @param _amount Amount of tokens to burn. function crosschainBurn(address _from, uint256 _amount) external onlyTokenBridge { _burn(_from, _amount); - emit CrosschainBurn(_from, _amount); + emit CrosschainBurn(_from, _amount, msg.sender); } function supportsInterface(bytes4 interfaceId) external pure override returns (bool) { From 58545701bc3d7b0ddfb3df775df94108a5e41aca Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Tue, 19 Nov 2024 12:30:22 -0300 Subject: [PATCH 19/26] feat: added rationale on function separation --- ERCS/erc-7802.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index 87d4651600a..2de053b4f19 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -98,6 +98,7 @@ Note: implementations might consider additionally emitting `Transfer(_from, addr ## Rationale +### Design philosophy The core design decisions behind this minimal interface are - Bridge agnosticism. @@ -120,6 +121,34 @@ The interface is intentionally neutral and does not impose conditions on: - **Access Control**: Token issuers determine who is authorized to call `crosschainMint()` and `crosschainBurn()`. - **Zero Amount Calls**: Token issuers decide whether to allow or revert calls with zero amounts. +### Separation of Local and Cross-Chain Minting/Burning + +**Different actions** + +Local minting and burning are fundamentally different from cross-chain minting and burning. + +- In cross-chain operations, the total circulating supply across all chains is expected to remain constant, as tokens are transferred between chains rather than created or destroyed in isolation. +- Agents that mint and burn tokens in cross-chain transfer fundamentally differ from token owners. It make sense for the two actors to have different permissions. + +Therefore, it is reasonable to have different checks, access controls, and logic (such as mint/burn limits) for cross-chain actions. + +**Separation of concerns** + +Merging local and cross-chain minting/burning into the same functions can lead to complex implementations that intertwine different operational logic. +By splitting into two, concerns remain separate, making the codebase cleaner and more maintainable. + +This separation of concerns is particularly relevant for + +- Upgrades: Any changes in access control, limits, or logic will only affect the separate cross-chain functions (`crosschainMint` and `crosschainBurn`) without altering the standard local mint and burn implementations. +- Integrations with Different Chains: To make an [ERC-20](./eip-20.md) cross-chain compatible, issuers simply need to implement the ERC-7802 extension with the corresponding access controls for each chain. +For example, when integrating with Optimism, the ERC-20 would grant access to the Optimism bridge; when integrating with Arbitrum, it would grant access to the Arbitrum bridge. +The local mint and burn functions remain unchanged. +Using dedicated functions for cross-chain operations provides a more modular approach, avoiding the need to modify the base implementation for each chain. + +**Dedicated events** + +A similar reasoning applies to having dedicated cross-chain-specific events. The separation significantly facilitates the work of indexers, analytics tools, and auditors. It allows for straightforward tracking of cross-chain activities, detecting anomalies, and monitoring bridge operations. If cross-chain and local events are indistinguishable, off-chain agents must implement complex logic to differentiate them, increasing the potential for errors and inefficiencies. + ### ERC-165 Interface The inclusion of ERC-165 provides an additional security check for integrators. By providing the interface identifier through the `supportsInterface` method, callers can programmatically confirm that the token adheres to the `IERC7802` interface. From bcea9feb6c3f3ded391e33690056635d722b101e Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Tue, 19 Nov 2024 13:29:57 -0300 Subject: [PATCH 20/26] chore: lint --- ERCS/erc-7802.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index 2de053b4f19..177efe69a67 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -140,7 +140,8 @@ By splitting into two, concerns remain separate, making the codebase cleaner and This separation of concerns is particularly relevant for - Upgrades: Any changes in access control, limits, or logic will only affect the separate cross-chain functions (`crosschainMint` and `crosschainBurn`) without altering the standard local mint and burn implementations. -- Integrations with Different Chains: To make an [ERC-20](./eip-20.md) cross-chain compatible, issuers simply need to implement the ERC-7802 extension with the corresponding access controls for each chain. +- Integrations with Different Chains: To make an [ERC-20](./eip-20.md) cross-chain compatible, +issuers simply need to implement the [ERC-7802](./eip-7802.md) extension with the corresponding access controls for each chain. For example, when integrating with Optimism, the ERC-20 would grant access to the Optimism bridge; when integrating with Arbitrum, it would grant access to the Arbitrum bridge. The local mint and burn functions remain unchanged. Using dedicated functions for cross-chain operations provides a more modular approach, avoiding the need to modify the base implementation for each chain. From 4fc3c980b641bfa5e550184cfd95489861cded8d Mon Sep 17 00:00:00 2001 From: parti <102677731+0xParticle@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:02:11 -0300 Subject: [PATCH 21/26] feat: remove explicit references to third-party standards Co-authored-by: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> --- ERCS/erc-7802.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index 177efe69a67..12de1feff63 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -23,7 +23,7 @@ However, each bridge implements a different interface for minting/burning on non This interface fragmentation is a massive issue in cross-chain communication among chains via third-party bridges or future canonical solutions. At this point, it is clear that every bridge would benefit from a standardized interface for minted/burnt tokens. -There have been different attempts in the past to standardize token-bridging interfaces. However, third-party providers are also developing cross-chain token frameworks, such as NTT by Wormhole and OFT by LayerZero. Each framework defines its features, like rate limits and fee switches, and implements its mint and burn versions. The resultant interfaces become highly specific, lacking naming conventions and structures. +There have been different attempts in the past to standardize token-bridging interfaces. However, third-party providers are also developing cross-chain token frameworks. Each framework defines its features, like rate limits and fee switches, and implements its mint and burn versions. The resultant interfaces become highly specific, lacking naming conventions and structures. The proposed interface includes the most relevant and minimal set of actions used by most of these standards. These actions also do not require any governance or owner participation, in contrast, for instance, to set rate limits. From 1c283af6a1fdb4a3b008b43891a0bc618ccfad61 Mon Sep 17 00:00:00 2001 From: parti <102677731+0xParticle@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:02:41 -0300 Subject: [PATCH 22/26] chore: includes 5679 in requirements Co-authored-by: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> --- ERCS/erc-7802.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index 12de1feff63..940ac10d146 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -8,7 +8,7 @@ status: Draft type: Standards Track category: ERC created: 2024-10-30 -requires: 165 +requires: 165, 5679 --- ## Abstract From 5d26ebb6e1c217a55e1aec461fad7ff57567556b Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Tue, 17 Dec 2024 15:31:02 -0300 Subject: [PATCH 23/26] chore: remove references to specific vendors, modified description and fix license in reference implementation --- ERCS/erc-7802.md | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index 940ac10d146..6a22726f0d7 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -1,7 +1,7 @@ --- eip: 7802 title: Crosschain Token Interface -description: Minimal token interface for cross-chain transfers +description: Token interface that allows bridges with mint and burn rights to send and relay token transfers with a standardized API author: skeletor (@skeletor-spaceman), parti (@0xParticle), joxes (@Joxess), ng (@0xng), agus duha (@agusduha), disco (@0xDiscotech), gotzen , 0age <0age@uniswap.org>, Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian , Blaine Malone (@blmalone) discussions-to: https://ethereum-magicians.org/t/erc-7802-crosschain-token-interface/21508 status: Draft @@ -17,9 +17,7 @@ This standard introduces a minimal interface for tokens to communicate cross-cha ## Motivation -All rollups and multiple important sidechains (Gnosis and Polygon PoS, among others) implement canonical bridges that embed their security into some part of the network's core architecture. These bridges do not have mint/burn rights over original tokens, so they usually lock (unlock) liquidity on the native chain and then mint (burn) a non-equivalent representation on the other. Mint/burn is used because the native token is non-existent on that side, so they must create a new representation. - -However, each bridge implements a different interface for minting/burning on non-native chains. For example, L1 bridged tokens need to support the `OptimismMintableERC20` specification when bridged (minted) to the OP Stack, but the `IArbToken` interface when bridged to the Arbitrum Stack. +All rollups and multiple important sidechains (Gnosis and Polygon PoS, among others) implement canonical bridges that embed their security into some part of the network's core architecture. These bridges do not have mint/burn rights over original tokens, so they usually lock (unlock) liquidity on the native chain and then mint (burn) a non-equivalent representation on the other. Mint/burn is used because the native token is non-existent on that side, so they must create a new representation. However, each bridge implements a different interface for minting/burning on non-native chains. This interface fragmentation is a massive issue in cross-chain communication among chains via third-party bridges or future canonical solutions. At this point, it is clear that every bridge would benefit from a standardized interface for minted/burnt tokens. @@ -166,25 +164,12 @@ As discussed in the Motivation section, a minimal, flexible cross-chain standard - Upgradable tokens can be upgraded to implement the new interface. - Non-upgradable tokens cannot implement the interface on the token itself. They can still migrate to a standard-compliant version using a lockbox mechanism, as proposed by xERC-20. The idea is to lock non-mintable tokens and mint the same amount of interface-compliant tokens. The bridge contract can act as a lockbox on the native chain. -Bridge contracts will also need an upgrade to integrate with the interface. Most popular bridges in terms of liquidity at the date are upgradable or use tokens that can be upgraded to point to new bridge contracts. - -1. Arbitrum One ($5.23B) -2. Portal Wormhole ($2.43B) -3. Polygon PoS ($2.15B) -4. OP Mainnet ($2.09B) -5. Mantle ($983M) -6. LayerZero OFTs ($465M) -7. Omnibridge ($449M) -8. Base ($350M) -9. Scroll ($128M) -10. zkSync ($77M) - -Source: L2Beat (10/31/24) +Bridge contracts will also need an upgrade to integrate with the interface. ## Reference Implementation ```solidity -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.25; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; From 34983adf9d6111b08ca2b321a78b0a1809a5c8af Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Tue, 17 Dec 2024 15:56:19 -0300 Subject: [PATCH 24/26] chore: improve Abstract --- ERCS/erc-7802.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index 6a22726f0d7..535c31d9e0f 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -13,7 +13,11 @@ requires: 165, 5679 ## Abstract -This standard 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. +This standard introduces a minimal interface, `IERC7802`, for tokens to enable standardized cross-chain communication. The interface consists of two functions, `crosschainMint` and `crosschainBurn`, which allow authorized bridge contracts to mint and burn token representations during cross-chain transfers. These functions serve as the entry points for bridge logic, enabling consistent handling of token supply across chains. + +The interface also defines two standardized events, `CrosschainMint` and `CrosschainBurn`, which emit metadata, including the target address, token amount, and caller. These events facilitate deterministic indexing and monitoring of cross-chain activities by off-chain agents, such as indexers, analytics tools, and auditors. + +`IERC7802` is intentionally lightweight, ensuring minimal overhead for implementation. Its modular design enables extensibility, allowing additional features—such as mint/burn limits, transfer fees, or bridge-specific access control mechanisms—to be layered on top without modifying the base interface. ## Motivation From c1fae24fbf2a13063b3e00f37ff0c6610fbdf66a Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Tue, 17 Dec 2024 16:03:25 -0300 Subject: [PATCH 25/26] lint: eip validator fix --- ERCS/erc-7802.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index 535c31d9e0f..6ddd7ac47cc 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -1,7 +1,7 @@ --- eip: 7802 title: Crosschain Token Interface -description: Token interface that allows bridges with mint and burn rights to send and relay token transfers with a standardized API +description: Token interface that allows authorized contracts to mint and burn token representations during cross-chain transfers author: skeletor (@skeletor-spaceman), parti (@0xParticle), joxes (@Joxess), ng (@0xng), agus duha (@agusduha), disco (@0xDiscotech), gotzen , 0age <0age@uniswap.org>, Mark Tyneway , Zain Bacchus , Matt Solomon , Maurelian , Blaine Malone (@blmalone) discussions-to: https://ethereum-magicians.org/t/erc-7802-crosschain-token-interface/21508 status: Draft From bf1ebe7d946d69c90c9f443df658fd37521b69f7 Mon Sep 17 00:00:00 2001 From: 0xParticle Date: Wed, 18 Dec 2024 11:45:00 -0300 Subject: [PATCH 26/26] feat: change invariants on the Transfer events to address 0 on calls to crosschainMint --- ERCS/erc-7802.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ERCS/erc-7802.md b/ERCS/erc-7802.md index 6ddd7ac47cc..eff764528f4 100644 --- a/ERCS/erc-7802.md +++ b/ERCS/erc-7802.md @@ -64,6 +64,8 @@ This function works as the minting entry point for bridge contracts. Each implem function crosschainMint(address _account, uint256 _amount) external; ``` +Implementations SHOULD emit `Transfer(address(0), _to, _amount)` on calls to `crosschainMint` to be compliant with [ERC-20](./eip-20.md) invariants on token creation. + **`crosschainBurn`** Burns `_amount` of token from address `_account`. @@ -74,6 +76,8 @@ This function works as the burning entry point for bridge contracts. Each implem function crosschainBurn(address _account, uint256 _amount) external; ``` +Implementations might consider emitting `Transfer(_from, address(0), _amount)` on calls to `crosschainBurn` to be compliant with [ERC-5679](./eip-5679.md). + ### Events **`CrosschainMint`** @@ -85,8 +89,6 @@ The `_sender` parameter MUST be set to the msg.sender at the time the function i event CrosschainMint(address indexed _to, uint256 _amount, address indexed _sender); ``` -Note: implementations might consider additionally emitting `Transfer(address(0), _to, _amount)` to be compliant with [ERC-5679](./eip-5679.md). - **`CrosschainBurn`** MUST trigger when `crosschainBurn` is successfully called. @@ -96,8 +98,6 @@ The `_sender` parameter MUST be set to the msg.sender at the time the function i event CrosschainBurn(address indexed _from, uint256 _amount, address indexed _sender) ``` -Note: implementations might consider additionally emitting `Transfer(_from, address(0), _amount)` to be compliant with [ERC-5679](./eip-5679.md). - ## Rationale ### Design philosophy