Skip to content

Upgrade ERC20 tokens for interop #1577

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
1 change: 1 addition & 0 deletions pages/interop/tutorials/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"deploy-superchain-erc20": "Deploying a SuperchainERC20",
"transfer-superchainERC20": "Transferring a SuperchainERC20",
"custom-superchain-erc20": "Custom SuperchainERC20 tokens",
"upgrade-to-superchain-erc20": "Upgrade ERC20 for Superchain support",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove duplicate key declaration
The key "upgrade-to-superchain-erc20" is declared twice in this JSON (once here and again later), causing the first occurrence to be ignored. Remove one entry to prevent unexpected behavior.

-    "upgrade-to-superchain-erc20": "Upgrade ERC20 for Superchain support",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"upgrade-to-superchain-erc20": "Upgrade ERC20 for Superchain support",
🧰 Tools
🪛 Biome (1.9.4)

[error] 6-6: The key upgrade-to-superchain-erc20 was already declared.

This where a duplicated key was declared again.

If a key is defined multiple times, only the last definition takes effect. Previous definitions are ignored.

(lint/suspicious/noDuplicateObjectKeys)

🤖 Prompt for AI Agents
In pages/interop/tutorials/_meta.json at line 6, the key
"upgrade-to-superchain-erc20" is declared twice, causing the first declaration
to be ignored. Locate both occurrences of this key and remove one of them to
eliminate the duplicate key and prevent unexpected behavior in the JSON file.

"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
2 changes: 1 addition & 1 deletion pages/interop/tutorials/message-passing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ For development purposes, we'll first use autorelay mode to handle message execu

6. Create `src/GreetingSender.sol`.

```solidity file=<rootDir>/public/tutorials/GreetingSender.sol#L1-L28 hash=75d197d1e1da112421785c2160f6a55a
```solidity file=<rootDir>/public/tutorials/GreetingSender.sol#L1-L28 hash=9ed77001810caf52bbaa94da8b0dc5c6
```

<details>
Expand Down
58 changes: 58 additions & 0 deletions pages/interop/tutorials/upgrade-to-superchain-erc20.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
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](/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](/interop/superchain-erc20).

{/*

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 your circumstances:

{/*

* If you can upgrade the existing contract, but the address is not available on other chains? In that case, use a custom bridge

upgrade-to-superchain-erc20/custom-bridge.

*/}

| When To Use | Action |
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| You can install a new ERC20 contract | [**Deploy New SuperchainERC20 contracts** directly](/interop/tutorials/deploy-superchain-erc20) |
| Existing ERC20 contract cannot be upgraded | [**Implement Lockbox Solution** to bridge between tokens](/interop/tutorials/upgrade-to-superchain-erc20/lockbox) |
| You can deploy to other chains using the same proxy address | [**Perform Contract Upgrade** while maintaining address](/interop/tutorials/upgrade-to-superchain-erc20/contract-upgrade) |

<Cards>
<Card title="Contract upgrade" href="/interop/tutorials/upgrade-to-superchain-erc20/contract-upgrade" icon={<img src="/img/icons/shapes.svg" />} />

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

## Next steps

* Deploy a [SuperchainERC20](/interop/tutorials/deploy-superchain-erc20) to the Superchain
* [Learn more about SuperchainERC20](/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 @@
{
"contract-upgrade": "Contract upgrade",
"lockbox": "Lockboxes for permissionless interop",
}
Loading