Skip to content

Commit df0e197

Browse files
Implement feedback
1 parent 79a3924 commit df0e197

File tree

1 file changed

+5
-47
lines changed

1 file changed

+5
-47
lines changed

pages/stack/interop/deploy-superchain-erc20.mdx

+5-47
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Steps } from 'nextra/components'
1313
Interop is currently in active development and not yet ready for production use. The information provided here may change. Check back regularly for the most up-to-date information.
1414
</Callout>
1515

16-
This guide explains how to issue new assets with the `SuperchainERC20` standard and bridge them effectively using the `SuperchainERC20Bridge`. If you want more information about the `SuperchainERC20 standard`, see our [`SuperchainERC20` standard explainer](/stack/interop/superchain-erc20)
16+
This guide explains how to issue new assets with the `SuperchainERC20` and bridge them effectively using the `SuperchainERC20Bridge`. If you want more information about the `SuperchainERC20 standard`, see our [`SuperchainERC20` standard explainer](/stack/interop/superchain-erc20)
1717

1818
An important thing to note is using `crosschainBurn` and `crosschainMint` on the `SuperchainERC20` to move your asset across the Superchain only affects which chain your asset is located on and does not change the overall supply of the token. This keeps the token’s total amount the same across all networks, ensuring its value stays stable during the move and that the `SuperchainERC20` retains a unified, global supply count.
1919

@@ -28,63 +28,21 @@ To ensure fungibility across chains, the SuperchainERC20 assets need to have the
2828
* `Create2Deployer`: A smart contract that enables deploying contracts with predictable addresses.
2929
* `OptimismSuperchainERC20Factory`: A factory contract designed for L1-native tokens to ensure uniform deployments across chains.
3030

31-
There are [many ways to do this](https://github.com/Arachnid/deterministic-deployment-proxy), but here's an example smart contract to start:
32-
33-
```solidity
34-
// Example token deployment using Create2Deployer
35-
bytes32 salt = keccak256(abi.encodePacked("SuperchainToken"));
36-
address tokenAddress = Create2Deployer.deploy(salt, bytecode, constructorArgs);
37-
```
31+
There are [many ways to do this](https://github.com/Arachnid/deterministic-deployment-proxy), but [here's an example smart contract to start](https://github.com/ethereum-optimism/superchainerc20-starter/blob/main/packages/contracts/src/L2NativeSuperchainERC20.sol)
3832

3933
By deploying assets at identical addresses across multiple chains, we abstract away the complexity of cross-chain validation.
4034

41-
### Implement the ICrosschainERC20 interface
42-
43-
Ensure that your token contract conforms to the `ICrosschainERC20` interface to support cross-chain minting and burning.
44-
45-
```solidity
46-
interface ICrosschainERC20 {
47-
function crosschainMint(address _account, uint256 _amount) external; /// Mints _amount of token to address _account.
48-
function crosschainBurn(address _account, uint256 _amount) external; /// Burns _amount of token from address _account.
49-
50-
event CrosschainMint(address indexed _to, uint256 _amount); /// MUST trigger when crosschainMint is called
51-
event CrosschainBurn(address indexed _from, uint256 _amount); /// MUST trigger when crosschainBurn is called
52-
}
53-
```
54-
55-
### Use the `SuperchainERC20Bridge` for cross-chain transfers
35+
### Implement the IERC7802 interface
5636

57-
The `SuperchainERC20Bridge` relies on the `L2ToL2CrossDomainMessenger` to securely relay messages between chains and provide replay protection, domain binding and access to additional message information.
37+
Implementations of `SuperchainERC2` will be required to implement the [IERC7802](https://specs.optimism.io/interop/token-bridging.html#ierc7802) interface, that includes two external functions and two events.
5838

5939
We'll use two function for bridging:
6040

6141
* `sendERC20`: initializes a cross-chain transfer of a `SuperchainERC20` by burning the tokens locally and sending a message to the `SuperchainERC20Bridge` on the target chain using the `L2toL2CrossDomainMessenger`. This ensures that asset supply never changes; sending an asset moves it from one chain to another, it does not "create" an additional asset in regards to supply.
6242
* `relayERC20`: process incoming messages from the L2toL2CrossDomainMessenger and mints the corresponding amount of the SuperchainERC20.
6343

64-
Here's an example implementation of the `SuperchainERC20Bridge`
65-
66-
```solidity
67-
function sendERC20(SuperchainERC20 _token, address _to, uint256 _amount, uint256 _chainId) external returns (bytes32 msgHash_) {
68-
_token.crosschainBurn(msg.sender, _amount);
69-
70-
bytes memory _message = abi.encodeCall(this.relayERC20, (_token, msg.sender, _to, _amount));
71-
72-
msgHash_ = L2ToL2CrossDomainMessenger.sendMessage(_chainId, address(this), _message);
73-
74-
emit SentERC20(address(_token), msg.sender, _to, _amount, _chainId);
75-
}
76-
77-
function relayERC20(SuperchainERC20 _token, address _from, address _to, uint256 _amount) external {
78-
require(msg.sender == address(L2ToL2CrossChainMessenger));
79-
require(L2ToL2CrossChainMessenger.crossDomainMessageSender() == address(this));
80-
81-
uint256 _source = L2ToL2CrossChainMessenger.crossDomainMessageSource();
82-
83-
_token.crosschainMint(_to, _amount);
44+
[Here's an example implementation of the `SuperchainERC20Bridge`](https://specs.optimism.io/interop/token-bridging.html#implementation)
8445

85-
emit RelayedERC20(address(_token), _from, _to, _amount, _source);
86-
}
87-
```
8846
</Steps>
8947

9048
## Next steps

0 commit comments

Comments
 (0)