-
Notifications
You must be signed in to change notification settings - Fork 97
docs(l2): add quick handsOn on bridging assets between L1 and L2 #2589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
5d92300
dd13147
531d7ff
66ddb4b
d699f5b
d0c3723
af8cb5b
3ee1b24
f2f5aa7
8f730eb
43ed241
d63e83e
feb4eba
0e45603
5e728a7
54adfb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,71 @@ Make sure docker is running! | |
|
||
For more information on how to run the L2 node with the prover attached to it, the [Prover Docs](./prover.md) provides more insight. | ||
|
||
## Bridge Assets | ||
|
||
### Funding an L2 Account from L1 | ||
|
||
To transfer ETH from Ethereum L1 to your L2 account: | ||
|
||
1. Prerequisites: | ||
- An L1 account with sufficient ETH balance | ||
- The address of the deployed CommonBridge contract | ||
- An Ethereum utility tool like [Rex](https://github.com/lambdaclass/rex) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😉 |
||
|
||
2. Make a deposit: | ||
|
||
Using Rex is as simple as: | ||
```Shell | ||
# Format: rex l2 deposit <AMOUNT> <PRIVATE_KEY> <BRIDGE_ADDRESS> [L2_RPC_URL] | ||
rex l2 deposit 50000000 0xbcdf20249abf0ed6d944c0288fad489e33f66b3960d9e6229c1cd214ed3bbe31 0x65dd6dc5df74b7e08e92c910122f91d7b2d5184f | ||
``` | ||
|
||
3. Verification: | ||
|
||
Once the deposit is made you can verify the balance has increase with: | ||
```Shell | ||
# Format: rex l2 balance <Address> [RPC_URL] | ||
rex l2 balance 0x8943545177806ed17b9f23f0a21ee5948ecaa776 | ||
``` | ||
|
||
For more information on what you can do with the CommonBridge see [here](./contracts.md). | ||
|
||
### Withdrawing funds from the L2 to L1 | ||
|
||
1. Prerequisites: | ||
- An L2 account with sufficient ETH balance | ||
- The address of the deployed CommonBridge L2 contract (note here that we are calling the L2 contract instead of the L1 as in the deposit case) | ||
- An Ethereum utility tool like [Rex](https://github.com/lambdaclass/rex) | ||
|
||
2. Make the Withdraw: | ||
|
||
Using Rex we simply use the `rex l2 withdraw` command. | ||
```Shell | ||
# Format: rex l2 withdraw <AMOUNT> <PRIVATE_KEY> [RPC_URL] | ||
rex l2 withdraw 5000 0xbcdf20249abf0ed6d944c0288fad489e33f66b3960d9e6229c1cd214ed3bbe31 | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would add a comment saying that if successful, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I second this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
|
||
3. Claim the Withdraw: | ||
|
||
After making the withdraw it has to be claimed in the L1. This is done with the L1 CommonBridge contract. We can use the Rex command `rex l2 claim-withdraw`. Here we have to use the tx hash obtained in the previous step. Also, it is necessary to wait for the block that includes the withdraw to be committed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Here we have to use the tx hash obtained in the previous step. Also, it is necessary to wait for the block that includes the withdraw to be verified. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! 54adfb5 |
||
|
||
```Shell | ||
# Format: rex l2 claim-withdraw <L2_WITHDRAWAL_TX_HASH> <PRIVATE_KEY> <BRIDGE_ADDRESS> | ||
rex l2 claim-withdraw <L2_WITHDRAWAL_TX_HASH> 0xbcdf20249abf0ed6d944c0288fad489e33f66b3960d9e6229c1cd214ed3bbe31 0x65dd6dc5df74b7e08e92c910122f91d7b2d5184f | ||
``` | ||
|
||
4. Verification: | ||
|
||
Once the withdrawal is made you can verify the balance has decrease with: | ||
```Shell | ||
rex l2 balance 0x8943545177806ed17b9f23f0a21ee5948ecaa776 | ||
``` | ||
|
||
And also increased in the L1: | ||
```Shell | ||
rex balance 0x8943545177806ed17b9f23f0a21ee5948ecaa776 | ||
``` | ||
|
||
## Configuration | ||
|
||
Configuration consists of two steps, the parsing of a `.toml` config file and the creation and modification of a `.env` file, then each component reads the `.env` to load the environment variables. A detailed list is available in each part documentation. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When developing locally, the value of this address is always the same. Let's put it here for reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 5e728a7