token-withdraw
shows how to move ERC-20 tokens from a chain to its parent chain (e.g. from Arbitrum to Ethereum).
Note that this repo covers initiating a token withdrawal; for a demo on releasing the funds from the Outbox, see outbox-execute
To withdraw a token from an Arbitrum chain, a message is send from a gateway contract which burns the token on the origin chain, and sends a message to its parent chain, which allow the token to be released from escrow once the dispute period is expired.
For more info, see child-to-parent messages.
In this tutorial, we deploy a fresh token and then deposit some to the child chain. Then, we use these new tokens to trigger a withdrawal back to the parent chain.
We use our Arbitrum SDK library for the token bridge interactions.
See ./exec.js for inline explanation.
Set the values shown in .env-sample
as environmental variables. To copy it into a .env
file:
cp .env-sample .env
You'll still need to edit some variables, i.e., PRIVATE_KEY
, CHAIN_RPC
and PARENT_CHAIN_RPC
.
Note that you can also set the environment variables in an .env
file in the root of the monorepo, which will be available in all tutorials.
yarn run token-withdraw