Skip to content

feat(cli): add support for withdraws and claiming withdraws on erc20 tokens #163

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

Open
wants to merge 5 commits into
base: feat/sdk/support-erc20-withdraw
Choose a base branch
from

Conversation

tomip01
Copy link
Contributor

@tomip01 tomip01 commented Jul 11, 2025

Motivation

Important

Merge after #162

We want to add an interface on the cli for the withdraw of erc20 tokens

Description

  • Introduced new parameters token_l1 and token_l2 in the Command enum for both Withdraw and ClaimWithdraw commands. These parameters allow specifying ERC20 token addresses on L1 and L2, respectively, with validation to ensure token_l2 is required when token_l1 is provided.
  • Modified the ClaimWithdraw command logic to handle ERC20 claims using the new claim_erc20withdraw function when token_l1 is specified. Otherwise, it defaults to the existing claim_withdraw function.
  • Updated the Withdraw command logic to support ERC20 withdrawals using the withdraw_erc20 function when token_l1 is specified. Otherwise, it defaults to the existing withdraw function.

How to test

  • Deploy contracts on L1 an L2 for the tokens.
    • You could use the same for the integration tests in ethrex repository. You can use the test test_erc20_roundtrip. Comment the parts of the withdrawals
  • Then run rex l2 withdraw <AMOUNT> <PRIVATE_KEY> --token-l1 <TOKEN_L1_ADDRESS> --token-l2 <TOKEN_L2_ADDRESS>
    • This will print a hash for a tx WITHDRAW_TX_HASH
  • Lastly, run rex l2 claim-withdraw <AMOUNT> <WITHDRAW_TX_HASH> <PRIVATE_KEY> <BRIDGE_ADDRESS> --token-l1 <TOKEN_L1_ADDRESS> --token-l2 <TOKEN_L2_ADDRESS>
  • You can check balances with:
    • rex l2 balance <ADDRESS> --token <L2_TOKEN_ADDRESS> for L2
    • rex balance <ADDRESS> --token <L1_TOKEN_ADDRESS> for L1

Note

verifying the batches is needed for claiming the withdraws
On ethrex run make init-prover on crates/l2

Closes #158
Closes #156

@tomip01 tomip01 self-assigned this Jul 11, 2025
@tomip01 tomip01 requested a review from a team as a code owner July 11, 2025 15:45
@tomip01 tomip01 added the enhancement New feature or request label Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support ERC20 withdrawals in rex-cli Support ERC20 withdrawals
2 participants