-
Notifications
You must be signed in to change notification settings - Fork 2
feat(sdk): add function to withdraw erc20 tokens #162
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
Merged
Merged
+99
−6
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MegaRedHand
approved these changes
Jul 17, 2025
iovoid
reviewed
Jul 21, 2025
tomip01
added a commit
that referenced
this pull request
Jul 28, 2025
…tokens (#163) **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 --------- Co-authored-by: Ivan Litteri <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
We want to add support for the withdraw of erc20 tokens in the sdk.
Description
withdraw_erc20
and theclaim_erc20withdraw
function insdk/src/l2/withdraw.rs
to handle ERC20 token withdrawals.L2_WITHDRAW_SIGNATURE_ERC20
andCLAIM_WITHDRAWAL_ERC20_SIGNATURE
insdk/src/l2/constants.rs
to define the signature for ERC20 withdrawal calldata encoding.Closes #157