token-withdraw
shows how to move ERC20 tokens from Arbitrum (Layer 2) into Ethereum (Layer 1).
Note that this repo covers initiating a token withdrawal; for a demo on (later) releasing the funds from the Outbox, see outbox-execute
To withdraw a token from Arbitrum, a message is send from a Gateway contract which burns the token on L2, and sends a message to L1, which allow the token to be released from escrow once the dispute period is expired. For more info, see Outgoing messages documentation.
In this demo, we deploy a fresh token and then deposit some to L2. Then, we use these new tokens to trigger a withdrawal back to L1.
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., DEVNET_PRIVKEY
)
yarn withdraw-token