Skip to content

Commit cad3ad9

Browse files
committed
Comments addressed
1 parent 3968ad1 commit cad3ad9

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

Diff for: pages/stack/interop/tutorials/upgrade-to-superchain-erc20/lockbox.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ show what is possible, it does the exact job needed.
4949

5050
Create a lockbox `SuperchainERC20` contract to permissionlessly enable interop.
5151

52-
## Step by step
52+
## Instructions
5353

5454
Some steps depend on whether you want to deploy on [supersim](/stack/interop/tools/supersim) or on the [development network](/stack/interop/tools/devnet).
5555

Diff for: pages/stack/interop/tutorials/upgrade-to-superchain-erc20/proxy-upgrade.mdx

+36-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Callout, Steps, Tabs } from 'nextra/components'
1515

1616
## Overview
1717

18-
This guide explains how to upgrade an ERC20 to a [`SuperchainERC20`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/SuperchainERC20.sol) that can teleport across the [Superchain interop cluster](/stack/interop/explainer#superchain-interop-cluster) using the [`SuperchainTokenBridge`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/SuperchainTokenBridge.sol) contract. For more information on how it works, [see the explainer](/stack/interop/superchain-erc20).
18+
This guide explains how to upgrade an ERC20 to a [`SuperchainERC20`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/SuperchainERC20.sol) that can teleport across the [Superchain interop cluster](/stack/interop/explainer#superchain-interop-cluster) when the original ERC20 contract was placed behind a proxy to enable future upgrades.
1919

2020
<details>
2121
<summary>About this tutorial</summary>
@@ -48,7 +48,40 @@ show what is possible, it does the exact job needed.
4848

4949
* Upgrade an existing ERC-20 that uses [the proxy pattern](https://docs.openzeppelin.com/upgrades-plugins/proxies) to comply with interop requirements (with the proper authority).
5050

51-
## Step by step
51+
52+
## How beacon proxies work
53+
54+
```mermaid
55+
sequenceDiagram
56+
Actor User
57+
User->>BeaconProxy: transfer(<address>, <amount>)
58+
BeaconProxy->>UpgradeableBeacon: What is the implementation address?
59+
UpgradeableBeacon->>BeaconProxy: It is 0xBAD0...60A7
60+
BeaconProxy->>0xBAD0...60A7: transfer(<address>, <amount>)
61+
```
62+
63+
A [beacon proxy](https://docs.openzeppelin.com/contracts/3.x/api/proxy#BeaconProxy) uses two contracts.
64+
The [`UpgradeableBeacon`](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/beacon/UpgradeableBeacon.sol) contract holds the address of the implementation contract.
65+
The [`BeaconProxy`](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/beacon/BeaconProxy.sol) contract is the one called for the functionality, the one that holds the storage.
66+
When a user (or another contract) calls `BeaconProxy`, it asks `UpgradeableBeacon` for the implementation address and then uses [`delegatecall`](https://www.evm.codes/?fork=cancun#f4) to call that contract.
67+
68+
```mermaid
69+
sequenceDiagram
70+
Actor User
71+
Actor Owner
72+
Participant BeaconProxy
73+
Participant 0x600D...60A7
74+
Owner->>UpgradeableBeacon: Your new implementation address is 0x600D...60A7
75+
User->>BeaconProxy: transfer(<address>, <amount>)
76+
BeaconProxy->>UpgradeableBeacon: What is the implementation address?
77+
UpgradeableBeacon->>BeaconProxy: It is 0x600D...60A7
78+
BeaconProxy->>0x600D...60A7: transfer(<address>, <amount>)
79+
```
80+
81+
To upgrade the contract, an authorized address (typically the `Owner`) calls `UpgradeableBeacon` directly to specify the new implementation contract address.
82+
After that happens, all new calls are sent to the new implementation.
83+
84+
## Instructions
5285

5386
Some steps depend on whether you want to deploy on [supersim](/stack/interop/tools/supersim) or on the [development network](/stack/interop/tools/devnet).
5487

@@ -274,7 +307,7 @@ Some steps depend on whether you want to deploy on [supersim](/stack/interop/too
274307

275308
```sh
276309
AMOUNT=`echo 0.1 | cast to-wei`
277-
cast send $INTEROP_BRIDGE --rpc-url $URL_CHAIN_A --private-key $PRIVATE_KEY "sendERC20(address,address,uint256,uint256)" $ERC20_ADDRESS $USER_ADDRESS $AMOUNT 902
310+
cast send $INTEROP_BRIDGE --rpc-url $URL_CHAIN_A --private-key $PRIVATE_KEY "sendERC20(address,address,uint256,uint256)" $ERC20_ADDRESS $USER_ADDRESS $AMOUNT `cast chain-id --rpc-url $URL_CHAIN_B`
278311
```
279312

280313
4. See the new balances. The A chain should have 0.9 tokens, and the B chain should have 0.1 tokens.

0 commit comments

Comments
 (0)