Skip to content

Commit

Permalink
Merge branch 'main' into op-supervisor
Browse files Browse the repository at this point in the history
  • Loading branch information
cpengilly authored Oct 31, 2024
2 parents 337f95e + d0b4b76 commit b4abe13
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pages/stack/interop/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"cross-chain-message": "Anatomy of cross-chain message",
"supersim": "Supersim Multichain Development Environment",
"superchain-erc20": "SuperchainERC20",
"op-supervisor": "OP Supervisor"
"op-supervisor": "OP Supervisor",
"transfer-superchainERC20": "How to transfer a SuperchainERC20"
}
8 changes: 4 additions & 4 deletions pages/stack/interop/superchain-erc20.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import { Callout } from 'nextra/components'
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.
</Callout>

`SuperchainERC20` is designed to enable asset interoperability in the Superchain.
`SuperchainERC20` is an implementation of [ERC-7802](https://ethereum-magicians.org/t/erc-7802-crosschain-token-interface/21508) designed to enable asset interoperability in the Superchain.
Asset interoperability allows for tokens to securely move across chains without asset wrapping or liquidity pools for maximal capital efficiency, thus unifying liquidity and simplifying the user experience.

Additional features:

* **Simplified deployments**: Provides a consistent, unified implementation for tokens across all Superchain-compatible networks and a common crosschain interface for the EVM ecosystem at large.
* **Simplified deployments**: 0-infrastructure cost to make your token cross-chain. Provides a consistent, unified implementation for tokens across all Superchain-compatible networks and a common cross-chain interface for the EVM ecosystem at large.
* **Permissionless propagation**: Easily clone an existing token contract to a new OP Stack chain using `create2` without requiring the original owner, which enables movement of assets to the new chain once Interop goes live. Importantly, permissionless propagation retains the integrity of the original owner on the contract and preserves security but proliferates the contract's availability to new chains.
* **Ethereum-aligned**: Intentionally designed to be generic and supported as an Ethereum-wide implementation (RIP coming soon).
* **Common standard**: Implements ERC-7802, a unified interface that can be used across all of Ethereum to enable cross-chain mint/burn functionality.

## How it works

Expand Down Expand Up @@ -63,7 +63,7 @@ This diagram illustrates the process where tokens are burned on the source chain

`SuperchainERC20` differs from other token implementations in its focus and implementation:

* `SuperchainERC20` has minimal differentiation from an ERC20 deployment, only requiring a minimal crosschain mint/burn interface, which aims to be a common pattern for the EVM ecosystem (RIP coming soon).
* `SuperchainERC20` implements ERC-7802, which provides a minimal crosschain mint/burn interface designed to be a common pattern for the EVM ecosystem.
* `SuperchainERC20` shares trust assumptions across all chains in the Superchain, such that custom assumptions around security and latency are not required to account for when executing transfers.

<Callout type="info">
Expand Down
117 changes: 117 additions & 0 deletions pages/stack/interop/transfer-superchainERC20.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
title: How to transfer a SuperchainERC20
lang: en-US
description: Learn how to transfer a SuperchainERC20 between chains using L2ToL2CrossDomainMessenger.
---

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

# How to transfer a SuperchainERC20

<Callout>
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.
</Callout>

This guide provides an overview of transferring `SuperchainERC20` tokens between chains.

## Overview

Transferring SuperchainERC20 tokens between chains involves two main phases:

1. **Source Chain Operations**
* Mint tokens if needed
* Initiate the transfer using the bridge
2. **Destination Chain Operations**
* Relay the transfer message
* Verify the transfer completion

<Callout type="warning">
Always verify your addresses and amounts before sending transactions. Cross-chain transfers cannot be reversed.
</Callout>

## How it works

This diagram illustrates the process of a SuperchainERC20 token transfer between chains.
Through the `L2ToL2CrossDomainMessenger` contract, tokens are burned on the source chain and a transfer message is emitted.
This message must then be relayed to the destination chain, where an equivalent amount of tokens will be minted to the specified recipient address - ensuring secure cross-chain transfers while maintaining the total token supply across all chains.

```mermaid
sequenceDiagram
actor User
participant SourceChain
participant Bridge as L2ToL2CrossDomainMessenger
participant DestChain
Note over User,DestChain: Step 1: Prepare Tokens
User->>SourceChain: Check token balance
alt
User->>SourceChain: Mint or acquire tokens
end
Note over User,DestChain: Step 2: Initiate Transfer
User->>SourceChain: Approve bridge contract
User->>Bridge: Call sendERC20
Bridge->>SourceChain: Burn tokens
Bridge-->>Bridge: Emit transfer message
Note over User,DestChain: Step 3: Complete Transfer
User->>Bridge: Get message details
User->>Bridge: Relay message on destination
Bridge->>DestChain: Mint tokens to recipient
Note over User,DestChain: Step 4: Verify
User->>DestChain: Check token balance
```

<Steps>
### Step 1: Prepare your tokens

Ensure you have tokens on the source chain using one of these methods:

* Use existing tokens you already own
* Mint new tokens using the [SuperchainERC20](https://github.com/ethereum-optimism/supersim/blob/main/contracts/src/L2NativeSuperchainERC20.sol) contract if you have minting permissions
* Acquire tokens through a supported exchange or transfer

### Step 2: Initiate the transfer

To start the transfer:

1. Choose the destination chain where you want to receive the tokens
2. Specify the recipient address and the amount to transfer
3. Call the bridge contract, which will:
* Lock or burn your tokens on the source chain
* Emit a message that will be used to mint tokens on the destination chain

### Step 3: Complete the transfer

To finalize the transfer on the destination chain:

1. Get the message details from the source chain event
2. Use the `L2ToL2CrossDomainMessenger` contract to relay the message
3. The message relay will trigger the minting of tokens on the destination chain

<Callout type="info">
The transfer isn't complete until the message is successfully relayed on the destination chain. See the [technical reference guide](https://supersim.pages.dev/guides/interop/manually-relaying-interop-messages-cast) for specific relay instructions.
</Callout>

### Step 4: Verify completion

After relaying the message:

1. Check your token balance on the destination chain
2. Confirm the transferred amount matches what you sent
3. The tokens should now be available for use on the destination chain
</Steps>

For detailed technical instructions including contract addresses, specific commands, and message relaying details, refer to our [technical reference guide](https://supersim.pages.dev/guides/interop/manually-relaying-interop-messages-cast).

## Alternative methods

You can also use:

* [viem bindings/actions](https://supersim.pages.dev/guides/interop/relay-using-viem) for TypeScript integration

## Next steps

* Read the [Superchain Interop Explainer](/stack/interop/explainer#faqs) or check out this [Superchain interop design video walk-thru](https://www.youtube.com/watch?v=FKc5RgjtGes)
* Use [Supersim](supersim), a local dev environment that simulates Superchain interop for testing applications against a local version of the Superchain

0 comments on commit b4abe13

Please sign in to comment.