Skip to content

Tutorial: Upgrade ERC20 to support interop #1525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7fbd348
WIP
qbzzt Mar 22, 2025
3697d7d
WIP
qbzzt Mar 22, 2025
c1ed880
Auto-fix: Update breadcrumbs, spelling dictionary and other automated…
qbzzt Mar 22, 2025
a4f98e2
Proxy method works
qbzzt Mar 24, 2025
ac5de2c
Auto-fix: Update breadcrumbs, spelling dictionary and other automated…
qbzzt Mar 24, 2025
6c6fd85
Added explanation of InteropToken.sol
qbzzt Mar 24, 2025
eb9ba15
Auto-fix: Update breadcrumbs, spelling dictionary and other automated…
qbzzt Mar 24, 2025
7327294
fixes
qbzzt Mar 24, 2025
0f4388b
WIP
qbzzt Mar 29, 2025
c75befd
Auto-fix: Update breadcrumbs, spelling dictionary and other automated…
qbzzt Mar 29, 2025
7644214
Need to polish
qbzzt Mar 30, 2025
a93acb3
Auto-fix: Update breadcrumbs, spelling dictionary and other automated…
qbzzt Mar 30, 2025
0c49dfe
WIP
qbzzt Apr 1, 2025
fdc7a7f
Ready for review
qbzzt Apr 1, 2025
33b49ed
Auto-fix: Update breadcrumbs, spelling dictionary and other automated…
qbzzt Apr 1, 2025
cdebe0f
Lint
qbzzt Apr 2, 2025
11e0b32
Code rabbit suggestions
qbzzt Apr 2, 2025
e059449
WIP, some @zainbacchu comments
qbzzt Apr 2, 2025
4b8033b
WIP
qbzzt Apr 2, 2025
921101d
WIP
qbzzt Apr 3, 2025
ca937f7
Auto-fix: Update breadcrumbs, spelling dictionary and other automated…
qbzzt Apr 3, 2025
3685944
lint
qbzzt Apr 3, 2025
63f4021
Merge branch 'main' into 250320-upgrade-erc20-to-superchain
qbzzt Apr 3, 2025
523dbbc
Multiple changes
qbzzt Apr 4, 2025
5b92cb7
WIP
qbzzt Apr 4, 2025
73f1f9f
WIP
qbzzt Apr 4, 2025
3968ad1
Almost ready
qbzzt Apr 4, 2025
cad3ad9
Comments addressed
qbzzt Apr 4, 2025
b0b71a2
Lint
qbzzt Apr 4, 2025
9330958
breadcrumbs
qbzzt Apr 4, 2025
25ce3e2
Update pages/stack/interop/tutorials/upgrade-to-superchain-erc20/lock…
qbzzt Apr 4, 2025
4640c8a
Update proxy-upgrade.mdx
qbzzt Apr 4, 2025
1eb5657
Import Card(s)
qbzzt Apr 4, 2025
384c99d
Update pages/stack/interop/tutorials/upgrade-to-superchain-erc20.mdx
qbzzt Apr 4, 2025
9bcaaeb
Code rabbit
qbzzt Apr 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pages/stack/interop/tutorials.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ Documentation covering Interop related tutorials.

<Card title="Creating custom SuperchainERC20 tokens" href="/stack/interop/tutorials/custom-superchain-erc20" icon={<img src="/img/icons/shapes.svg" />} />

<Card title="Upgrading ERC-20 tokens for interop support" href="/stack/interop/tutorials/upgrade-to-superchain-erc20" icon={<img src="/img/icons/shapes.svg" />} />

</Cards>
3 changes: 2 additions & 1 deletion pages/stack/interop/tutorials/_meta.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"message-passing": "Interop message passing",
"deploy-superchain-erc20": "Deploying a SuperchainERC20",
"upgrade-to-superchain-erc20": "Upgrading ERC20 to SuperchainERC20",
"transfer-superchainERC20": "Transferring a SuperchainERC20",
"custom-superchain-erc20": "Custom SuperchainERC20 tokens",
"custom-superchain-erc20": "Creating a custom SuperchainERC20",
"bridge-crosschain-eth": "Bridging native cross-chain ETH transfers",
"relay-messages-cast": "Relaying interop messages using `cast`",
"relay-messages-viem": "Relaying interop messages using `viem`",
Expand Down
4 changes: 2 additions & 2 deletions pages/stack/interop/tutorials/custom-superchain-erc20.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Custom SuperchainERC20 tokens
title: Creating a custom SuperchainERC20
description: Create SuperchainERC20 tokens with custom behaviors
lang: en-US
content_type: tutorial
Expand All @@ -26,7 +26,7 @@ import { Steps } from 'nextra/components'
Please note that the OP Stack interoperability upgrade, required for crosschain messaging, is currently still in active development.
</Callout>

# Custom SuperchainERC20 tokens
# Creating a custom SuperchainERC20

## Overview

Expand Down
5 changes: 5 additions & 0 deletions pages/stack/interop/tutorials/deploy-superchain-erc20.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ This requirement abstracts away the complexity of cross-chain validation.
Achieving this requires deterministic deployment methods. There are multiple ways to do this.
Here we will use the [SuperchainERC20 Starter Kit](/app-developers/starter-kit).

<Callout>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using ./ in links- this can cause issues when we move files around if the directory structure changes.

This tutorial teaches you how to deploy a *new* `SuperchainERC20`.
If you're looking to migrate an existing ERC20 visit [this tutorial](./upgrade-to-superchain-erc20).
</Callout>

### What you'll do

* Use the [SuperchainERC20 Starter Kit](/app-developers/starter-kit) to deploy an `SuperchainERC20` token on the devnet.
Expand Down
65 changes: 65 additions & 0 deletions pages/stack/interop/tutorials/upgrade-to-superchain-erc20.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: Upgrading ERC20 to SuperchainERC20
lang: en-US
description: Tutorial on how to take an existing ERC20 and upgrade it to SuperchainERC20.
topic: Interoperability
personas: [Developer]
categories: [Tutorial, Interop]
content_type: article
---

import { Callout, Steps, Card, Cards } from 'nextra/components'

<Callout>
The SuperchainERC20 standard is ready for production deployments.
Please note that the OP Stack interoperability upgrade, required for crosschain messaging, is currently still in active development.
</Callout>

# Upgrading ERC20 to SuperchainERC20

## Overview

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).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is teleport the correct phrasing here? Doesn't seem accurate unless we're using that language elsewhere


<Callout type="warning">
The code on the documentation site is sample code, *not* production code.
This means that we ran it, and it works as advertised.
However, it did not pass through the rigorous audit process that most Optimism code undergoes.
You're welcome to use it, but if you need it for production purposes you should get it audited first.
</Callout>

{/*

I put this warning here, when we don't have it on most pages, because this tutorial
has, IMHO, code that is a lot more likely to be used in production. It doesn't just
show what is possible, it does the exact job needed.

*/}

There are several ways to upgrade an existing ERC20 for interop, depending on the exact circumstances. Click any of the green rectangles for directions.

```mermaid
graph TB
classDef link fill:#f96
Deployed{Is there<br/>already an<br/>ERC20 contract<br/>in use?}
Deployed -- No --> New[<a href="./deploy-superchain-erc20">New SuperchainERC20 contract</a>]:::link
Deployed -- Yes --> Proxy{Is the<br/>existing contract</br>behind a<br/>proxy?}
Proxy -- No --> Lockbox[<a href="upgrade-to-superchain-erc20/lockbox">Lockbox contract</a>]:::link
Proxy -- Yes --> Proxy2{Can you<br/>deploy proxies on<br/>the same address<br/>on the other chains?}
Proxy2 -- No --> Bridge[Specialized Bridge<br/>Coming soon]
Proxy2 -- Yes --> Upgrade[<a href="upgrade-to-superchain-erc20/proxy-upgrade">Contract upgrade</a>]:::link
```


<Cards>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also i'm not sure what the relationship between the diagram above and these cards. Do we need both??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need the cards. But I can't get past the automatic checks without them.


<Card title="Contract upgrade" href="/stack/interop/tutorials/upgrade-to-superchain-erc20/proxy-upgrade" icon={<img src="/img/icons/shapes.svg" />} />
<Card title="Lockboxes for permissionless interop" href="/stack/interop/tutorials/upgrade-to-superchain-erc20/lockbox" icon={<img src="/img/icons/shapes.svg" />} />

</Cards>

## Next steps

* Deploy a [SuperchainERC20](./deploy-superchain-erc20) to the Superchain
* [Learn more about SuperchainERC20](/stack/interop/superchain-erc20)
* Build a [revolutionary app](/app-developers/get-started) that uses multiple blockchains within the Superchain
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"lockbox": "Lockboxes for permissionless interop",
"proxy-upgrade": "Contract upgrade"
}
Loading