From b70d6daec6aeee7e2ebf251c10fdf7ebc5a8b317 Mon Sep 17 00:00:00 2001 From: Ori Pomerantz Date: Tue, 18 Feb 2025 10:54:32 -0600 Subject: [PATCH 1/7] WIP --- pages/stack/interop/tutorials/_meta.json | 1 + .../stack/interop/tutorials/custom-erc20.mdx | 63 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 pages/stack/interop/tutorials/custom-erc20.mdx diff --git a/pages/stack/interop/tutorials/_meta.json b/pages/stack/interop/tutorials/_meta.json index f69605cf5..0bcd09f05 100644 --- a/pages/stack/interop/tutorials/_meta.json +++ b/pages/stack/interop/tutorials/_meta.json @@ -2,6 +2,7 @@ "message-passing": "Interop message passing", "transfer-superchainERC20": "Transferring a SuperchainERC20", "deploy-superchain-erc20": "Issuing new assets with SuperchainERC20", + "custom-erc20": "Creating custom SuperchainERC20 tokens", "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`", diff --git a/pages/stack/interop/tutorials/custom-erc20.mdx b/pages/stack/interop/tutorials/custom-erc20.mdx new file mode 100644 index 000000000..6a2dc659a --- /dev/null +++ b/pages/stack/interop/tutorials/custom-erc20.mdx @@ -0,0 +1,63 @@ +--- +title: Creating custom SuperchainERC20 tokens +lang: en-US +description: +--- + +import { Callout } from 'nextra/components' +import { Steps } from 'nextra/components' + + +The SuperchainERC20 standard is ready for production use with active Mainnet deployments. +Please note that the OP Stack interoperability upgrade, required for crosschain messaging, is currently still in active development. + + +# Issuing new assets with SuperchainERC20 + +This guide explains how to issue new assets with the `SuperchainERC20` and bridge them effectively using the `SuperchainERC20Bridge`. If you want more information about the `SuperchainERC20 standard`, see our [`SuperchainERC20` standard explainer](/stack/interop/superchain-erc20) + +Note that bridging assets through the Superchain using `SuperchainERC20` never affects the total supply of your asset. The supply remains fixed, and bridging only changes the chain on which your asset is located. This keeps the token's total amount the same across all networks, ensuring its value stays stable during the move and that the `SuperchainERC20` retains a unified, global supply count. + +## Steps to issue and bridge assets + + + + + Implementations of SuperchainERC20 will be required to implement the IERC7802 interface, that includes two external functions and two events. + + The interface defines two functions for bridging: + + +sendERC20: Initializes a cross-chain transfer of a SuperchainERC20 by burning the tokens locally and sending a message to the SuperchainERC20Bridge on the target chain using the L2toL2CrossDomainMessenger. This ensures that asset supply remains constant, as sending an asset moves it from one chain to another without creating additional supply. +relayERC20: Processes incoming messages from the L2toL2CrossDomainMessenger and mints the corresponding amount of the SuperchainERC20. + + Here's an example implementation of the SuperchainERC20Bridge + + + ### Deploy the `SuperchainERC20` Token Contract + + To ensure fungibility across chains, the SuperchainERC20 assets need to have the same contract address on all chains. Achieving this requires deterministic deployment methods, such as: + + * `Create2Deployer`: A smart contract that enables deploying contracts with predictable addresses. + * `OptimismSuperchainERC20Factory`: A factory contract designed for L1-native tokens to ensure uniform deployments across chains. + + There are [many ways to do this](https://github.com/Arachnid/deterministic-deployment-proxy), but [here's an example smart contract to start](https://github.com/ethereum-optimism/superchainerc20-starter/blob/main/packages/contracts/src/L2NativeSuperchainERC20.sol). For an in-depth guide on how to deploy a `SuperchainERC20` use the [SuperchainERC20 Starter Kit](/app-developers/starter-kit). + + By deploying assets at identical addresses across multiple chains, we abstract away the complexity of cross-chain validation. + + ### Implement the IERC7802 interface + + Implementations of `SuperchainERC20` will be required to implement the [IERC7802](https://specs.optimism.io/interop/token-bridging.html#ierc7802) interface, that includes two external functions and two events. + + The interface defines two functions for bridging: + + * `sendERC20`: Initializes a cross-chain transfer of a `SuperchainERC20` by burning the tokens locally and sending a message to the `SuperchainERC20Bridge` on the target chain using the `L2toL2CrossDomainMessenger`. This ensures that asset supply remains constant, as sending an asset moves it from one chain to another without creating additional supply. + * `relayERC20`: Processes incoming messages from the L2toL2CrossDomainMessenger and mints the corresponding amount of the SuperchainERC20. + + [Here's an example implementation of the `SuperchainERC20Bridge`](https://specs.optimism.io/interop/token-bridging.html#implementation) + + +## Next steps +* Use the [SuperchainERC20 Starter Kit](/app-developers/starter-kit) to deploy your token across the Superchain. +* Explore the [SuperchainERC20 specifications](https://specs.optimism.io/interop/token-bridging.html) for in-depth implementation details. +* Review the [Superchain Interop Explainer](../explainer) for answers to common questions about interoperability. From 91febcf129a793175b04538eacefdf72ac222498 Mon Sep 17 00:00:00 2001 From: Ori Pomerantz Date: Wed, 19 Feb 2025 10:04:17 -0600 Subject: [PATCH 2/7] First draft of tutorial for creating custom SuperchainERC20 contracts Note: Needs to be merged after #1376 --- pages/stack/interop/tutorials/_meta.json | 2 +- .../stack/interop/tutorials/custom-erc20.mdx | 63 ------- .../tutorials/custom-superchain-erc20.mdx | 173 ++++++++++++++++++ public/tutorials/CustomSuperchainToken.sol | 39 ++++ 4 files changed, 213 insertions(+), 64 deletions(-) delete mode 100644 pages/stack/interop/tutorials/custom-erc20.mdx create mode 100644 pages/stack/interop/tutorials/custom-superchain-erc20.mdx create mode 100644 public/tutorials/CustomSuperchainToken.sol diff --git a/pages/stack/interop/tutorials/_meta.json b/pages/stack/interop/tutorials/_meta.json index 0bcd09f05..f5bbd35b9 100644 --- a/pages/stack/interop/tutorials/_meta.json +++ b/pages/stack/interop/tutorials/_meta.json @@ -2,7 +2,7 @@ "message-passing": "Interop message passing", "transfer-superchainERC20": "Transferring a SuperchainERC20", "deploy-superchain-erc20": "Issuing new assets with SuperchainERC20", - "custom-erc20": "Creating custom SuperchainERC20 tokens", + "custom-superchain-erc20": "Creating custom SuperchainERC20 tokens", "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`", diff --git a/pages/stack/interop/tutorials/custom-erc20.mdx b/pages/stack/interop/tutorials/custom-erc20.mdx deleted file mode 100644 index 6a2dc659a..000000000 --- a/pages/stack/interop/tutorials/custom-erc20.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -title: Creating custom SuperchainERC20 tokens -lang: en-US -description: ---- - -import { Callout } from 'nextra/components' -import { Steps } from 'nextra/components' - - -The SuperchainERC20 standard is ready for production use with active Mainnet deployments. -Please note that the OP Stack interoperability upgrade, required for crosschain messaging, is currently still in active development. - - -# Issuing new assets with SuperchainERC20 - -This guide explains how to issue new assets with the `SuperchainERC20` and bridge them effectively using the `SuperchainERC20Bridge`. If you want more information about the `SuperchainERC20 standard`, see our [`SuperchainERC20` standard explainer](/stack/interop/superchain-erc20) - -Note that bridging assets through the Superchain using `SuperchainERC20` never affects the total supply of your asset. The supply remains fixed, and bridging only changes the chain on which your asset is located. This keeps the token's total amount the same across all networks, ensuring its value stays stable during the move and that the `SuperchainERC20` retains a unified, global supply count. - -## Steps to issue and bridge assets - - - - - Implementations of SuperchainERC20 will be required to implement the IERC7802 interface, that includes two external functions and two events. - - The interface defines two functions for bridging: - - -sendERC20: Initializes a cross-chain transfer of a SuperchainERC20 by burning the tokens locally and sending a message to the SuperchainERC20Bridge on the target chain using the L2toL2CrossDomainMessenger. This ensures that asset supply remains constant, as sending an asset moves it from one chain to another without creating additional supply. -relayERC20: Processes incoming messages from the L2toL2CrossDomainMessenger and mints the corresponding amount of the SuperchainERC20. - - Here's an example implementation of the SuperchainERC20Bridge - - - ### Deploy the `SuperchainERC20` Token Contract - - To ensure fungibility across chains, the SuperchainERC20 assets need to have the same contract address on all chains. Achieving this requires deterministic deployment methods, such as: - - * `Create2Deployer`: A smart contract that enables deploying contracts with predictable addresses. - * `OptimismSuperchainERC20Factory`: A factory contract designed for L1-native tokens to ensure uniform deployments across chains. - - There are [many ways to do this](https://github.com/Arachnid/deterministic-deployment-proxy), but [here's an example smart contract to start](https://github.com/ethereum-optimism/superchainerc20-starter/blob/main/packages/contracts/src/L2NativeSuperchainERC20.sol). For an in-depth guide on how to deploy a `SuperchainERC20` use the [SuperchainERC20 Starter Kit](/app-developers/starter-kit). - - By deploying assets at identical addresses across multiple chains, we abstract away the complexity of cross-chain validation. - - ### Implement the IERC7802 interface - - Implementations of `SuperchainERC20` will be required to implement the [IERC7802](https://specs.optimism.io/interop/token-bridging.html#ierc7802) interface, that includes two external functions and two events. - - The interface defines two functions for bridging: - - * `sendERC20`: Initializes a cross-chain transfer of a `SuperchainERC20` by burning the tokens locally and sending a message to the `SuperchainERC20Bridge` on the target chain using the `L2toL2CrossDomainMessenger`. This ensures that asset supply remains constant, as sending an asset moves it from one chain to another without creating additional supply. - * `relayERC20`: Processes incoming messages from the L2toL2CrossDomainMessenger and mints the corresponding amount of the SuperchainERC20. - - [Here's an example implementation of the `SuperchainERC20Bridge`](https://specs.optimism.io/interop/token-bridging.html#implementation) - - -## Next steps -* Use the [SuperchainERC20 Starter Kit](/app-developers/starter-kit) to deploy your token across the Superchain. -* Explore the [SuperchainERC20 specifications](https://specs.optimism.io/interop/token-bridging.html) for in-depth implementation details. -* Review the [Superchain Interop Explainer](../explainer) for answers to common questions about interoperability. diff --git a/pages/stack/interop/tutorials/custom-superchain-erc20.mdx b/pages/stack/interop/tutorials/custom-superchain-erc20.mdx new file mode 100644 index 000000000..2584924c8 --- /dev/null +++ b/pages/stack/interop/tutorials/custom-superchain-erc20.mdx @@ -0,0 +1,173 @@ +--- +title: Creating custom SuperchainERC20 tokens +lang: en-US +description: Create SuperchainERC20 tokens with custom behaviors +--- + +import { Callout } from 'nextra/components' +import { Steps } from 'nextra/components' + + +The SuperchainERC20 standard is ready for production use with active Mainnet deployments. +Please note that the OP Stack interoperability upgrade, required for crosschain messaging, is currently still in active development. + + +# Creating custom SuperchainERC20 tokens + +## Overview + +This guide explains how to modify the behavior of [`SuperchainERC20`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/SuperchainERC20.sol) contracts to create custom tokens that can then be bridged quickly and safely using the [`SuperchainTokenBridge` ](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/SuperchainTokenBridge.sol) contract (once interop is operational). +For more information on how it works, [see the explainer](/stack/interop/superchain-erc20). + +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). +Here we will use the [SuperchainERC20 Starter Kit](/app-developers/starter-kit). + +### What you'll do + +* Use the [SuperchainERC20 Starter Kit](/app-developers/starter-kit) to deploy tokens with your custom code. + +### What you'll learn + +* How to deploy custom ERC-20 tokens on different 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. + +## Prerequisites + +Before starting this tutorial, ensure your development environment meets the following requirements: + +### Technical knowledge + +* Understanding of smart contract development +* Familiarity with blockchain concepts +* Familiarity with [standard SuperchainERC20 deployments](./deploy-superchain-erc20). + +### Development environment + +* Unix-like operating system (Linux, macOS, or WSL for Windows) +* Git for version control + +### Required tools + +The tutorial uses these primary tools: + +* Foundry: For sending transactions to blockchains. + +## Step by step explanation + + + + ### Prepare for deployment + + 1. Follow the setup steps in the [SuperchainERC20 Starter Kit](/app-developers/starter-kit#setup). + Don't start the development environment (step 5). + + 1. Follow [the deployment preparations steps](./deploy-superchain-erc20#prepare-for-deployment) in the issuing new assets page. + Don't deploy the contracts yet. + + **Note:** Make sure to specify a previously unused value for the salt, for example your address and a timestamp. + 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. + + ### Create the custom contract + + The easiest way to do this is to copy and modify the `L2NativeSuperchainERC20.sol` contract. + Use this code, for example, as `packages/contracts/src/CustomSuperchainToken.sol`. + + ```typescript file=/public/tutorials/CustomSuperchainToken.sol hash=4ad95b9203ce523351eba0501f8b972d + ``` + +
+ + Explanation + + ```typescript file=/public/tutorials/CustomSuperchainToken.sol#L36-L38 hash=4e402ea88c9cd796500425172a6de16d + ``` + + This function lets users get tokens for themselves. + This token is for testing purposes, so it is useful for users to get their own tokens to run tests. + +
+ + ### Deploy the new token + + 1. Edit `packages/contracts/scripts/SuperchainERC20Deployer.s.sol`: + + - Change line 6 to import the new token. + + ```solidity + import {CustomSuperchainToken} from "../src/CustomSuperchainToken.sol"; + ``` + + - Change lines 52-54 to get the `CustomSuperchainToken` initialization code. + + ```solidity + bytes memory initCode = abi.encodePacked( + type(CustomSuperchainToken).creationCode, abi.encode(ownerAddr_, name, symbol, uint8(decimals)) + ); + ``` + + - Change line 62 to deploy a `CustomSuperchainToken` contract. + + ```solidity + addr_ = address(new CustomSuperchainToken{salt: _implSalt()}(ownerAddr_, name, symbol, uint8(decimals))); + ``` + + 1. Deploy the token contract. + + ```sh + pnpm contracts:deploy:token + ``` + +
+ + Sanity check + + 1. Set `TOKEN_ADDRESS` to the address where the token is deployed. + You can also play with the token I created, which is at address [`0xF3Ce0794cB4Ef75A902e07e5D2b75E4D71495ee8`](https://sid.testnet.routescan.io/address/0xF3Ce0794cB4Ef75A902e07e5D2b75E4D71495ee8). + + ```sh + TOKEN_ADDRESS=0xF3Ce0794cB4Ef75A902e07e5D2b75E4D71495ee8 + ``` + + 1. Source the `.env` file to get the private key and the address to which it corresponds. + + ```sh + . packages/contracts/.env + MY_ADDRESS=`cast wallet address $DEPLOYER_PRIVATE_KEY` + ``` + + 1. Set variables for the RPC URLs. + + ```sh + RPC_DEV0=https://interop-alpha-0.optimism.io + RPC_DEV1=https://interop-alpha-1.optimism.io + ``` + + 1. Get your current balance (it should be zero). + + ```sh + cast call --rpc-url $RPC_DEV0 $TOKEN_ADDRESS "balanceOf(address)" $MY_ADDRESS | cast to-dec | cast --from-wei + ``` + + 1. Call the faucet to get a token and check the balance again. + + ```sh + cast send --private-key $DEPLOYER_PRIVATE_KEY --rpc-url $RPC_DEV0 $TOKEN_ADDRESS "faucet()" + cast call --rpc-url $RPC_DEV0 $TOKEN_ADDRESS "balanceOf(address)" $MY_ADDRESS | cast to-dec | cast --from-wei + ``` + +
+ +
+ +## How does this work? + +To allow for superchain interoperability, an ERC-20 token has to implement [ERC-7802](https://specs.optimism.io/interop/token-bridging.html#ierc7802). +You can either use [the `SuperchainERC20` implementation](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/SuperchainERC20.sol#L26-L46), or write your own. + +For more details [see the explainer](../superchain-erc20). + +## Next steps +* Use the [SuperchainERC20 Starter Kit](/app-developers/starter-kit) to deploy your token across the Superchain. +* Explore the [SuperchainERC20 specifications](https://specs.optimism.io/interop/token-bridging.html) for in-depth implementation details. +* Review the [Superchain Interop Explainer](../explainer) for answers to common questions about interoperability. diff --git a/public/tutorials/CustomSuperchainToken.sol b/public/tutorials/CustomSuperchainToken.sol new file mode 100644 index 000000000..20bd72f62 --- /dev/null +++ b/public/tutorials/CustomSuperchainToken.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +import {SuperchainERC20} from "./SuperchainERC20.sol"; +import {Ownable} from "@solady/auth/Ownable.sol"; + +contract CustomSuperchainToken is SuperchainERC20, Ownable { + string private _name; + string private _symbol; + uint8 private immutable _decimals; + + constructor(address owner_, string memory name_, string memory symbol_, uint8 decimals_) { + _name = name_; + _symbol = symbol_; + _decimals = decimals_; + + _initializeOwner(owner_); + } + + function name() public view virtual override returns (string memory) { + return _name; + } + + function symbol() public view virtual override returns (string memory) { + return _symbol; + } + + function decimals() public view override returns (uint8) { + return _decimals; + } + + function mintTo(address to_, uint256 amount_) external onlyOwner { + _mint(to_, amount_); + } + + function faucet() external { + _mint(msg.sender, 10**_decimals); + } +} From 0fc2e4ed3232a062cd8622194480a819a8c0b6b0 Mon Sep 17 00:00:00 2001 From: Ori Pomerantz Date: Wed, 19 Feb 2025 10:15:38 -0600 Subject: [PATCH 3/7] Lint --- .../tutorials/custom-superchain-erc20.mdx | 73 +++++++++---------- words.txt | 3 - 2 files changed, 34 insertions(+), 42 deletions(-) diff --git a/pages/stack/interop/tutorials/custom-superchain-erc20.mdx b/pages/stack/interop/tutorials/custom-superchain-erc20.mdx index 2584924c8..3d25a5c75 100644 --- a/pages/stack/interop/tutorials/custom-superchain-erc20.mdx +++ b/pages/stack/interop/tutorials/custom-superchain-erc20.mdx @@ -8,15 +8,15 @@ import { Callout } from 'nextra/components' import { Steps } from 'nextra/components' -The SuperchainERC20 standard is ready for production use with active Mainnet deployments. -Please note that the OP Stack interoperability upgrade, required for crosschain messaging, is currently still in active development. + The SuperchainERC20 standard is ready for production use with active Mainnet deployments. + Please note that the OP Stack interoperability upgrade, required for crosschain messaging, is currently still in active development. # Creating custom SuperchainERC20 tokens ## Overview -This guide explains how to modify the behavior of [`SuperchainERC20`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/SuperchainERC20.sol) contracts to create custom tokens that can then be bridged quickly and safely using the [`SuperchainTokenBridge` ](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/SuperchainTokenBridge.sol) contract (once interop is operational). +This guide explains how to modify the behavior of [`SuperchainERC20`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/SuperchainERC20.sol) contracts to create custom tokens that can then be bridged quickly and safely using the [`SuperchainTokenBridge`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/SuperchainTokenBridge.sol) contract (once interop is operational). For more information on how it works, [see the explainer](/stack/interop/superchain-erc20). To ensure fungibility across chains, `SuperchainERC20` assets *must* have the same contract address on all chains. @@ -30,7 +30,7 @@ Here we will use the [SuperchainERC20 Starter Kit](/app-developers/starter-kit). ### What you'll learn -* How to deploy custom ERC-20 tokens on different 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. +* How to deploy custom ERC-20 tokens on different 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. ## Prerequisites @@ -56,17 +56,16 @@ The tutorial uses these primary tools: ## Step by step explanation - ### Prepare for deployment - 1. Follow the setup steps in the [SuperchainERC20 Starter Kit](/app-developers/starter-kit#setup). - Don't start the development environment (step 5). + 1. Follow the setup steps in the [SuperchainERC20 Starter Kit](/app-developers/starter-kit#setup). + Don't start the development environment (step 5). - 1. Follow [the deployment preparations steps](./deploy-superchain-erc20#prepare-for-deployment) in the issuing new assets page. - Don't deploy the contracts yet. + 2. Follow [the deployment preparations steps](./deploy-superchain-erc20#prepare-for-deployment) in the issuing new assets page. + Don't deploy the contracts yet. - **Note:** Make sure to specify a previously unused value for the salt, for example your address and a timestamp. - 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. + **Note:** Make sure to specify a previously unused value for the salt, for example your address and a timestamp. + 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. ### Create the custom contract @@ -77,7 +76,6 @@ The tutorial uses these primary tools: ```
- Explanation ```typescript file=/public/tutorials/CustomSuperchainToken.sol#L36-L38 hash=4e402ea88c9cd796500425172a6de16d @@ -85,41 +83,39 @@ The tutorial uses these primary tools: This function lets users get tokens for themselves. This token is for testing purposes, so it is useful for users to get their own tokens to run tests. -
### Deploy the new token - 1. Edit `packages/contracts/scripts/SuperchainERC20Deployer.s.sol`: + 1. Edit `packages/contracts/scripts/SuperchainERC20Deployer.s.sol`: - - Change line 6 to import the new token. + * Change line 6 to import the new token. - ```solidity - import {CustomSuperchainToken} from "../src/CustomSuperchainToken.sol"; - ``` + ```solidity + import {CustomSuperchainToken} from "../src/CustomSuperchainToken.sol"; + ``` - - Change lines 52-54 to get the `CustomSuperchainToken` initialization code. + * Change lines 52-54 to get the `CustomSuperchainToken` initialization code. - ```solidity - bytes memory initCode = abi.encodePacked( - type(CustomSuperchainToken).creationCode, abi.encode(ownerAddr_, name, symbol, uint8(decimals)) - ); - ``` + ```solidity + bytes memory initCode = abi.encodePacked( + type(CustomSuperchainToken).creationCode, abi.encode(ownerAddr_, name, symbol, uint8(decimals)) + ); + ``` - - Change line 62 to deploy a `CustomSuperchainToken` contract. + * Change line 62 to deploy a `CustomSuperchainToken` contract. - ```solidity - addr_ = address(new CustomSuperchainToken{salt: _implSalt()}(ownerAddr_, name, symbol, uint8(decimals))); - ``` + ```solidity + addr_ = address(new CustomSuperchainToken{salt: _implSalt()}(ownerAddr_, name, symbol, uint8(decimals))); + ``` - 1. Deploy the token contract. + 2. Deploy the token contract. - ```sh - pnpm contracts:deploy:token - ``` + ```sh + pnpm contracts:deploy:token + ```
- Sanity check 1. Set `TOKEN_ADDRESS` to the address where the token is deployed. @@ -129,35 +125,33 @@ The tutorial uses these primary tools: TOKEN_ADDRESS=0xF3Ce0794cB4Ef75A902e07e5D2b75E4D71495ee8 ``` - 1. Source the `.env` file to get the private key and the address to which it corresponds. + 2. Source the `.env` file to get the private key and the address to which it corresponds. ```sh . packages/contracts/.env MY_ADDRESS=`cast wallet address $DEPLOYER_PRIVATE_KEY` ``` - 1. Set variables for the RPC URLs. + 3. Set variables for the RPC URLs. ```sh RPC_DEV0=https://interop-alpha-0.optimism.io RPC_DEV1=https://interop-alpha-1.optimism.io ``` - 1. Get your current balance (it should be zero). + 4. Get your current balance (it should be zero). ```sh cast call --rpc-url $RPC_DEV0 $TOKEN_ADDRESS "balanceOf(address)" $MY_ADDRESS | cast to-dec | cast --from-wei ``` - 1. Call the faucet to get a token and check the balance again. + 5. Call the faucet to get a token and check the balance again. ```sh cast send --private-key $DEPLOYER_PRIVATE_KEY --rpc-url $RPC_DEV0 $TOKEN_ADDRESS "faucet()" cast call --rpc-url $RPC_DEV0 $TOKEN_ADDRESS "balanceOf(address)" $MY_ADDRESS | cast to-dec | cast --from-wei ``` -
-
## How does this work? @@ -168,6 +162,7 @@ You can either use [the `SuperchainERC20` implementation](https://github.com/eth For more details [see the explainer](../superchain-erc20). ## Next steps + * Use the [SuperchainERC20 Starter Kit](/app-developers/starter-kit) to deploy your token across the Superchain. * Explore the [SuperchainERC20 specifications](https://specs.optimism.io/interop/token-bridging.html) for in-depth implementation details. * Review the [Superchain Interop Explainer](../explainer) for answers to common questions about interoperability. diff --git a/words.txt b/words.txt index f4402123e..3ee228103 100644 --- a/words.txt +++ b/words.txt @@ -107,7 +107,6 @@ dripcheck Drippie Eigen EIPs -emmited ENABLEDEPRECATEDPERSONAL enabledeprecatedpersonal enginekind @@ -237,7 +236,6 @@ multichain multiclient multisigs MULTU -neccessary nethermind NETRESTRICT netrestrict @@ -420,7 +418,6 @@ undercollateralize Unichain unmetered Unprotect -unqiue unsubmitted UPNP VERKLE From e851568a1527b670342f6956709034ed5058f2cd Mon Sep 17 00:00:00 2001 From: Ori Pomerantz Date: Wed, 19 Feb 2025 13:14:48 -0600 Subject: [PATCH 4/7] From `cast--to-dec` --- pages/stack/interop/tutorials/custom-superchain-erc20.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/stack/interop/tutorials/custom-superchain-erc20.mdx b/pages/stack/interop/tutorials/custom-superchain-erc20.mdx index 3d25a5c75..2887357d3 100644 --- a/pages/stack/interop/tutorials/custom-superchain-erc20.mdx +++ b/pages/stack/interop/tutorials/custom-superchain-erc20.mdx @@ -142,14 +142,14 @@ The tutorial uses these primary tools: 4. Get your current balance (it should be zero). ```sh - cast call --rpc-url $RPC_DEV0 $TOKEN_ADDRESS "balanceOf(address)" $MY_ADDRESS | cast to-dec | cast --from-wei + cast call --rpc-url $RPC_DEV0 $TOKEN_ADDRESS "balanceOf(address)" $MY_ADDRESS | cast --from-wei ``` 5. Call the faucet to get a token and check the balance again. ```sh cast send --private-key $DEPLOYER_PRIVATE_KEY --rpc-url $RPC_DEV0 $TOKEN_ADDRESS "faucet()" - cast call --rpc-url $RPC_DEV0 $TOKEN_ADDRESS "balanceOf(address)" $MY_ADDRESS | cast to-dec | cast --from-wei + cast call --rpc-url $RPC_DEV0 $TOKEN_ADDRESS "balanceOf(address)" $MY_ADDRESS | cast --from-wei ``` From 8c618a74a29dc5313d697ed3f9fcff83b2779eff Mon Sep 17 00:00:00 2001 From: Ori Pomerantz Date: Thu, 20 Feb 2025 11:00:20 -0600 Subject: [PATCH 5/7] Coderabbit and lint --- pages/stack/interop/tutorials/custom-superchain-erc20.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/stack/interop/tutorials/custom-superchain-erc20.mdx b/pages/stack/interop/tutorials/custom-superchain-erc20.mdx index 2887357d3..29267cdc2 100644 --- a/pages/stack/interop/tutorials/custom-superchain-erc20.mdx +++ b/pages/stack/interop/tutorials/custom-superchain-erc20.mdx @@ -95,7 +95,7 @@ The tutorial uses these primary tools: import {CustomSuperchainToken} from "../src/CustomSuperchainToken.sol"; ``` - * Change lines 52-54 to get the `CustomSuperchainToken` initialization code. + * Update lines 52-54 to get the `CustomSuperchainToken` initialization code. ```solidity bytes memory initCode = abi.encodePacked( @@ -103,7 +103,7 @@ The tutorial uses these primary tools: ); ``` - * Change line 62 to deploy a `CustomSuperchainToken` contract. + * Modify line 62 to deploy a `CustomSuperchainToken` contract. ```solidity addr_ = address(new CustomSuperchainToken{salt: _implSalt()}(ownerAddr_, name, symbol, uint8(decimals))); From 98256cc3f4b24f22f1511703599b9885ce7d1436 Mon Sep 17 00:00:00 2001 From: Ori Pomerantz Date: Thu, 20 Feb 2025 11:22:29 -0600 Subject: [PATCH 6/7] Update custom-superchain-erc20.mdx --- pages/stack/interop/tutorials/custom-superchain-erc20.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/stack/interop/tutorials/custom-superchain-erc20.mdx b/pages/stack/interop/tutorials/custom-superchain-erc20.mdx index 29267cdc2..2e8a796be 100644 --- a/pages/stack/interop/tutorials/custom-superchain-erc20.mdx +++ b/pages/stack/interop/tutorials/custom-superchain-erc20.mdx @@ -8,7 +8,7 @@ import { Callout } from 'nextra/components' import { Steps } from 'nextra/components' - The SuperchainERC20 standard is ready for production use with active Mainnet deployments. + 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. From a95eddb397106425459b55cb84c1f2e2b0f081c7 Mon Sep 17 00:00:00 2001 From: Ori Pomerantz Date: Thu, 20 Feb 2025 15:37:54 -0600 Subject: [PATCH 7/7] Code rabbit --- pages/stack/interop/tutorials/_meta.json | 2 +- pages/stack/interop/tutorials/custom-superchain-erc20.mdx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/stack/interop/tutorials/_meta.json b/pages/stack/interop/tutorials/_meta.json index f5bbd35b9..87b1a2131 100644 --- a/pages/stack/interop/tutorials/_meta.json +++ b/pages/stack/interop/tutorials/_meta.json @@ -2,7 +2,7 @@ "message-passing": "Interop message passing", "transfer-superchainERC20": "Transferring a SuperchainERC20", "deploy-superchain-erc20": "Issuing new assets with SuperchainERC20", - "custom-superchain-erc20": "Creating custom SuperchainERC20 tokens", + "custom-superchain-erc20": "Custom SuperchainERC20 tokens", "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`", diff --git a/pages/stack/interop/tutorials/custom-superchain-erc20.mdx b/pages/stack/interop/tutorials/custom-superchain-erc20.mdx index 2e8a796be..9257b3877 100644 --- a/pages/stack/interop/tutorials/custom-superchain-erc20.mdx +++ b/pages/stack/interop/tutorials/custom-superchain-erc20.mdx @@ -12,7 +12,7 @@ import { Steps } from 'nextra/components' Please note that the OP Stack interoperability upgrade, required for crosschain messaging, is currently still in active development. -# Creating custom SuperchainERC20 tokens +# Custom SuperchainERC20 tokens ## Overview @@ -72,13 +72,13 @@ The tutorial uses these primary tools: The easiest way to do this is to copy and modify the `L2NativeSuperchainERC20.sol` contract. Use this code, for example, as `packages/contracts/src/CustomSuperchainToken.sol`. - ```typescript file=/public/tutorials/CustomSuperchainToken.sol hash=4ad95b9203ce523351eba0501f8b972d + ```solidity file=/public/tutorials/CustomSuperchainToken.sol hash=4ad95b9203ce523351eba0501f8b972d ```
Explanation - ```typescript file=/public/tutorials/CustomSuperchainToken.sol#L36-L38 hash=4e402ea88c9cd796500425172a6de16d + ```solidity file=/public/tutorials/CustomSuperchainToken.sol#L36-L38 hash=4e402ea88c9cd796500425172a6de16d ``` This function lets users get tokens for themselves.