Skip to content

Commit b828112

Browse files
committed
update custom gas token docs
1 parent 29d7fc5 commit b828112

File tree

2 files changed

+44
-31
lines changed

2 files changed

+44
-31
lines changed

pages/builders/chain-operators/management/custom-gas-token.mdx

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import { Callout, Steps } from 'nextra/components'
99
# How to Run a Custom Gas Token Chain
1010

1111
<Callout type="warning">
12-
We do not recommend running a Custom Gas Token chain in production mainnet yet.
13-
This guide is for running testnet chains. The OP Labs team will flag when they have confidence in the security of the implementation code.
12+
The Custom Gas Token feature is a Beta feature of the MIT licensed OP Stack. While it has received initial review from core contributors, it is still undergoing testing, and may have bugs or other issues.
1413
</Callout>
1514

1615
This guide provides a walkthrough for chain operators who want to run a custom gas token chain. See the [Custom Gas Token Explainer](/stack/protocol/features/custom-gas-token) for a general overview of this OP Stack feature.
@@ -19,28 +18,32 @@ An OP Stack chain that uses the custom gas token feature enables an end user to
1918
<Steps>
2019
### Deploying Your Contracts
2120

22-
* Checkout the [custom gas token branch](https://github.com/ethereum-optimism/optimism/pull/10143) and use the commit to deploy.
21+
* Checkout the [`v2.0.0-beta.1` of the contracts](https://github.com/ethereum-optimism/optimism/tree/op-contracts/v2.0.0-beta.1) and use the commit to deploy.
2322

2423
<Callout type="error">
25-
Be sure to check out this branch or you will not deploy a chain that uses custom gas token!
24+
Be sure to check out this tag or you will not deploy a chain that uses custom gas token!
2625
</Callout>
2726

2827
* Update the deploy config in `contracts-bedrock/deploy-config` with new fields: `useCustomGasToken` and `customGasTokenAddress`
2928

30-
* Set `useCustomGasToken` to `true` and the address of the L1 ERC20 token should be in `customGasTokenAddress`. The ERC20 should already be deployed before trying to spin up the custom gas token chain.
29+
* Set `useCustomGasToken` to `true`. If you set `useCustomGasToken` to `false` (it defaults this way), then it will use ETH as the gas paying token.
3130

32-
If you set `useCustomGasToken` to `false` (it defaults this way), then it will use ETH as the gas paying token.
33-
34-
* Set `customGasTokenAddress` to the contract address of an L1 ERC20 token you wish to use as the gas token on your L2.
31+
* Set `customGasTokenAddress` to the contract address of an L1 ERC20 token you wish to use as the gas token on your L2. The ERC20 should already be deployed before trying to spin up the custom gas token chain.
3532

3633
The custom gas token being set must meet the following criteria:
3734

35+
* must be a valid ERC-20 token
3836
* the number of decimals on the token MUST be exactly 18
3937
* the name of the token MUST be less than or equal to 32 bytes
4038
* symbol MUST be less than or equal to 32 bytes.
39+
* must not be yield-bearing
40+
* cannot be rebasing or have a transfer fee
41+
* must be transferrable only via a call to the token address itself
42+
* must only be able to set allowance via a call to the token address itself
43+
* must not have a callback on transfer, and more generally a user must not be able to make a transfer to themselves revert
4144

4245
<Callout type="warning">
43-
You will NOT be able to change the address of the custom gas token if it is already set.
46+
You will NOT be able to change the address of the custom gas token after it is set during deployment.
4447
</Callout>
4548

4649
* Deploy the L1 contracts from `contracts-bedrock` using the following command:
@@ -59,7 +62,7 @@ An OP Stack chain that uses the custom gas token feature enables an end user to
5962
### Generating L2 Allocs
6063

6164
<Callout type="info">
62-
Be sure to use the same branch that you used to deploy the L1 contracts.
65+
Be sure to use the same tag that you used to deploy the L1 contracts.
6366
</Callout>
6467

6568
A forge script is used to generate the L2 genesis. It is a requirement that the L1 contracts have been deployed before generating the L2 genesis, since some L1 contract addresses are embedded into the L2 genesis.
@@ -97,9 +100,9 @@ An OP Stack chain that uses the custom gas token feature enables an end user to
97100

98101
Ensure that the end to end system is running.
99102

100-
### Depositing Your Custom Gas Token into Your Chain
103+
### Depositing Custom Gas Token into the Chain
101104

102-
* To deposit your custom gas token into your chain, you must use the **`OptimismPortalProxy.depositERC20Transaction`** method
105+
* To deposit the custom gas token into the chain, users must use the **`OptimismPortalProxy.depositERC20Transaction`** method
103106
* Users MUST first `approve()` the `OptimismPortal` before they can deposit tokens using `depositERC20Transaction`.
104107

105108
```
@@ -112,6 +115,18 @@ An OP Stack chain that uses the custom gas token feature enables an end user to
112115
bytes memory _data
113116
) public;
114117
```
118+
119+
### Withdrawing Custom Gas Tokens out of the Chain
120+
121+
* To withdraw your native custom gas token from the chain, users must use the **`L2ToL1MessagePasser.initiateWithdrawal`** method. Proving and finalizing withdrawals is identical to the process on chains that use ETH as the native gas token.
122+
123+
```
124+
function initiateWithdrawal(
125+
address _target,
126+
uint256 _gasLimit,
127+
bytes memory _data
128+
) public payable;
129+
```
115130
</Steps>
116131

117132
## Next Steps

pages/stack/protocol/features/custom-gas-token.mdx

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ The Custom Gas Token configuration lets OP Stack chain operators deploy their ch
1717

1818
## Native Gas Tokens
1919

20-
By default, L2 OP Stack chains allow users to deposit ETH from L1 into the chain as the L2 ETH, the native token that can then be used to pay for gas fees.
20+
By default, L2 OP Stack chains allow users to deposit ETH from L1 into the L2 chain as native L2 token that can then be used to pay for gas fees.
2121
Chain operators wanted to configure the stack to use a custom token to pay for gas, other than ETH.
2222

23-
With custom gas tokens, chain operators can now set an L1 ERC-20 token address at the time of deploying the contracts of their chain.
23+
With custom gas tokens, chain operators can now set an L1 ERC-20 token address at the time of deploying the contracts of their L2 chain.
2424
When deposited, this L1 ERC-20 token will become the native gas token on the L2 and can be used to pay for gas fees.
2525

2626
<Callout type="warning">
2727
**Caveats chain operators should be aware of:**
2828

2929
* You cannot switch from your custom gas token to another token after the chain is launched.
30+
* Existing chains cannot switch to use a custom gas token. A custom token must be configured at the time of chain deployment.
3031
* You will need to manually modify your fee configuration values to properly charge fees for users.
3132
* Understand the [constraints required for your chain to be able to join the Superchain](#considerations) when setting the custom gas token for your chain.
3233
</Callout>
@@ -36,7 +37,7 @@ When deposited, this L1 ERC-20 token will become the native gas token on the L2
3637
This is the general flow of how custom gas tokens work on the OP Stack:
3738

3839
* On deployment of an L2 chain, set the address of an L1 token to be used as the gas token.
39-
* When depositing a custom gas token to L2, it mints the native L2 token.
40+
* When depositing the custom gas token to L2, it mints the native L2 token.
4041
* Withdrawing the native L2 token results in the unlocking of the custom token on L1.
4142
* The native L2 token is used by default to pay for gas fees.
4243

@@ -52,13 +53,16 @@ Chain operators get the following benefits by using custom gas tokens:
5253

5354
The custom token being used must adhere to the following constraints to be able to join the Superchain:
5455

55-
* Must be a non-yield bearing token (This is a requirement from Legal)
56-
* Must be a valid ERC-20 token
57-
* Must have 18 decimals
58-
* Can't be rebasing or have a transfer fee
59-
* Must only be transferrable via a call to the token address itself
60-
* Must only be able to set allowance via a call to the token address itself
61-
* Must not have a callback on transfer, and more generally a user must not be able to make a transfer to themselves revert
56+
* must be a valid ERC-20 token
57+
* the number of decimals on the token MUST be exactly 18
58+
* the name of the token MUST be less than or equal to 32 bytes
59+
* symbol MUST be less than or equal to 32 bytes.
60+
* must not be yield-bearing
61+
* cannot be rebasing or have a transfer fee
62+
* must be transferrable only via a call to the token address itself
63+
* must only be able to set allowance via a call to the token address itself
64+
* must not have a callback on transfer, and more generally a user must not be able to make a transfer to themselves revert
65+
6266

6367
## Next Steps
6468

@@ -75,19 +79,13 @@ The custom token being used must adhere to the following constraints to be able
7579

7680
### How do I charge fees as the chain operator?
7781

78-
The initial release of custom gas token does not have special logic for taking into account the exchange rate between the custom gas token and ether. This logic is nice to have because it requires ether to purchase data availability for Ethereum. If the chain is earning in a custom gas token and spending in ether, then it must earn enough custom gas token such that it can be sold for ether.
79-
80-
For the initial release of custom gas token, the chain operator will need to manage this either out of band or by manually tuning the fee parameters to ensure profitability. A future release may include [L1 Fee Abstraction](https://github.com/ethereum-optimism/specs/issues/73) where the L1 fee is calculated in a smart contract instead of native code. This would enable an on chain oracle to take into account the exchange rate of the custom gas token. This oracle could be something like Uniswap TWAP or Chainlink.
82+
The initial release of custom gas token does not have special logic for taking into account the exchange rate between the custom gas token and ether. Currently, the protocol charges fees for users with scalars on the L1 blob fee and L1 base fee in ETH. Chain operator will be taking user fees in the custom gas token and spending in ether.
8183

82-
### What's the best way to monitor my custom gas token chain?
83-
84-
It is important to monitor your custom gas token chain to see if your chain's bridge is undercollateralized by checking that the amount of ETH in the `OptimismPortal` is greater or equal to the amount of ETH on the L2. [Chain monitor](https://github.com/ethereum-optimism/optimism/tree/v1.7.4/packages/chain-mon) is one way to actively monitor your custom gas token chain.
84+
For the initial release of custom gas token, the chain operator will need to manage this either out of band or by manually tuning the fee scalar values to capture the exchange rate between ETH and the custom gas token to ensure profitability. A future release may include [L1 Fee Abstraction](https://github.com/ethereum-optimism/specs/issues/73) where the L1 fee is calculated in a smart contract instead of native code. This would enable an on chain oracle to take into account the exchange rate of the custom gas token.
8585

8686
### Can I migrate my chain into being custom gas token?
8787

88-
If you are already live using `ether` to pay for gas, you cannot become a custom gas token chain. It would require a large migration and chain downtime and it is not a service that we provide.
89-
90-
Custom gas token hack to standard gas token is possible with architectural changes. L1 and L2 architectural changes are required, messengers and bridges on both sides, OptimismPortal (L1), and SystemConfig (L1). Additional information can be found in the [specs](https://specs.optimism.io/protocol/granite/custom-gas-token.html).
88+
If you are already live using `ether` to pay for gas, you cannot become a custom gas token chain. This would likely require a risky, high lift state migration that we would not recommend.
9189

9290
### Do node operators need to do anything?
9391

0 commit comments

Comments
 (0)