You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SuperchainERC20 standard is ready for production deployments.
@@ -35,168 +34,112 @@ This guide explains how to upgrade an ERC20 to a [`SuperchainERC20`](https://git
35
34
To ensure fungibility across chains, `SuperchainERC20` assets must have the same contract address on all chains. This requirement abstracts away the complexity of cross-chain validation. Achieving this requires deterministic deployment methods. There are [many ways to do this](https://github.com/Arachnid/deterministic-deployment-proxy).
36
35
Here we will use the [SuperchainERC20 Starter Kit](/app-developers/starter-kit).
37
36
38
-
### What you'll do
39
-
40
-
* Use the [SuperchainERC20 Starter Kit](/app-developers/starter-kit) to deploy tokens with your custom code.
41
-
42
-
### What you'll learn
43
-
44
-
* How to deploy custom ERC20 tokens across multiple chains at the same address so that they can be bridged with the [`SuperchainTokenBridge`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/SuperchainTokenBridge.sol) contract.
45
-
46
-
### How does this work?
47
-
48
-
To benefit from Superchain Interoperability, an ERC-20 token has to implement [ERC-7802](https://eips.ethereum.org/EIPS/eip-7802). You can either use the SuperchainERC20 implementation, or write your own.
49
-
50
-
At a high level you will:
51
-
52
-
<Steps>
53
-
54
-
### Create a basic ERC20 contract
55
-
56
-
The following code implements a basic ERC20 contract:
57
-
58
-
```solidity
59
-
// SPDX-License-Identifier: MIT
60
-
pragma solidity ^0.8.20;
61
-
62
-
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
63
-
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
function mint(address to, uint256 amount) public onlyOwner {
69
-
_mint(to, amount);
70
-
}
71
-
}
72
-
73
-
```
74
-
75
-
### Add the new SuperchainERC20 interface
76
-
77
-
The first step is simply to implement [`IERC7802`](https://eips.ethereum.org/EIPS/eip-7802) and `IERC165`. Note that we've renamed the contract at this point:
78
-
79
-
```solidity
80
-
// SPDX-License-Identifier: MIT
81
-
pragma solidity ^0.8.20;
82
-
83
-
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
84
-
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
85
-
import {ERC165} from "@openzeppelin/contracts/interfaces/IERC165.sol";
86
-
import {IERC7802} from "@openzeppelin/contracts/token/ERC20/IERC7802.sol";
87
-
88
-
contract MySuperchainERC20 is ERC20, Ownable, IERC7802 {
function mint(address to, uint256 amount) public onlyOwner {
94
-
_mint(to, amount);
95
-
}
40
+
**What you'll learn**
96
41
42
+
* How to deploy custom ERC20 tokens across multiple chains at the same address so that they can be bridged with the [`SuperchainTokenBridge`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/SuperchainTokenBridge.sol) contract.
97
43
98
-
function supportsInterface(bytes4 _interfaceId) public view virtual returns (bool) {
* Familiarity with [standard SuperchainERC20 deployments](/interop/tutorials/deploy-superchain-erc20).
106
49
107
-
### Implement burn and mint functions
50
+
**Development environment**
108
51
109
-
There are two functions we need to implement: `CrosschainMint` and `CrosschainBurn`. These two functions allow two chains to bridge a token by burning them on one chain and mint them on another. Read more about these functions in our [SuperchainERC20 docs](/interop/superchain-erc20).
52
+
* Unix-like operating system (Linux, macOS, or WSL for Windows)
53
+
* Git for version control
54
+
</details>
110
55
111
-
Here's what our contract looks like once we've implemented the functions:
112
-
113
-
114
-
```solidity
115
-
// SPDX-License-Identifier: MIT
116
-
pragma solidity ^0.8.20;
56
+
### What you'll do
117
57
118
-
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
119
-
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
120
-
import {ERC165} from "@openzeppelin/contracts/interfaces/IERC165.sol";
121
-
import {IERC7802} from "@openzeppelin/contracts/token/ERC20/IERC7802.sol";
58
+
* Use the [SuperchainERC20 starter kit](/app-developers/starter-kit) to deploy tokens with your custom code.
122
59
123
-
contract MySuperchainERC20 is ERC20, Ownable, IERC7802 {
| salt<sup>1</sup> | A unique identifier | Carthage |
135
+
| chains | The chains to deploy the contract<sup>2</sup> |\["devnet0","devnet1"]|
194
136
195
-
2. Follow [the deployment preparations steps](./deploy-superchain-erc20#prepare-for-deployment) in the issuing new assets page.
196
-
Don't deploy the contracts yet.
137
+
(1) Make sure to specify a previously unused value for the salt, for example your address and a timestamp.
138
+
This is necessary because if the same constructor code is used with the same salt when using the deployment script, it gets the same address, which is a problem if you want a fresh deployment.
197
139
198
-
**Note:** Make sure to specify a previously unused value for the salt, for example your address and a timestamp.
199
-
This is necessary because if the same constructor code is used with the same salt when using the deployment script, it gets the same address, which is a problem if you want a fresh deployment.
140
+
(2) These names must correspond to the chain names in the `[rpc_endpoints]` section of `foundry.toml` you updated in the previous step.
141
+
</Tabs.Tab>
142
+
</Tabs>
200
143
201
144
### Create the custom contract
202
145
@@ -246,49 +189,70 @@ The tutorial uses these primary tools:
246
189
pnpm contracts:deploy:token
247
190
```
248
191
249
-
<details>
250
-
<summary>Sanity check</summary>
192
+
### Verify the installation
193
+
194
+
1. Set `TOKEN_ADDRESS` to the address where the token is deployed.
195
+
You can also play with a previously created token, which is at address [`0xF3Ce0794cB4Ef75A902e07e5D2b75E4D71495ee8`](https://sid.testnet.routescan.io/address/0xF3Ce0794cB4Ef75A902e07e5D2b75E4D71495ee8) on the devnets.
196
+
197
+
```sh
198
+
TOKEN_ADDRESS=<<<Your token address >>>
199
+
```
251
200
252
-
1. Set `TOKEN_ADDRESS` to the address where the token is deployed.
253
-
You can also play with the token I created, which is at address [`0xF3Ce0794cB4Ef75A902e07e5D2b75E4D71495ee8`](https://sid.testnet.routescan.io/address/0xF3Ce0794cB4Ef75A902e07e5D2b75E4D71495ee8).
201
+
2. Source the `.env` file to get the private key and the address to which it corresponds.
0 commit comments