|
| 1 | +--- |
| 2 | +head: |
| 3 | + - - meta |
| 4 | + - name: "twitter:title" |
| 5 | + content: Bridge Operations with zksync-cli | zkSync Docs |
| 6 | +--- |
| 7 | + |
| 8 | +# Bridge operations with zksync-cli |
| 9 | + |
| 10 | +Leverage the [zksync-cli](../../zksync-cli/getting-started.md) to facilitate bridge operations between Ethereum (L1) and zkSync (L2), including token deposits, withdrawals, and finalizing withdrawals. |
| 11 | + |
| 12 | +### Prerequisites |
| 13 | + |
| 14 | +Before you start, make sure you have installed: |
| 15 | + |
| 16 | +- [Node.js v18+](https://nodejs.org/en) |
| 17 | + |
| 18 | +### Table of contents |
| 19 | + |
| 20 | +- [Bridge Deposit](#bridge-deposit) |
| 21 | + - [Deposit Options](#deposit-options) |
| 22 | + - [Depositing ERC-20 Tokens](#depositing-erc-20-tokens) |
| 23 | +- [Bridge Withdraw](#bridge-withdraw) |
| 24 | + - [Withdraw Options](#withdraw-options) |
| 25 | + - [Withdrawing ERC-20 Tokens](#withdrawing-erc-20-tokens) |
| 26 | +- [Withdraw Finalize](#withdraw-finalize) |
| 27 | + - [Finalize Withdraw Options](#finalize-withdraw-options) |
| 28 | +- [Troubleshooting](#troubleshooting) |
| 29 | + |
| 30 | +## Bridge Deposit |
| 31 | + |
| 32 | +Transfer ETH from L1 to L2 using the deposit command. |
| 33 | + |
| 34 | +```bash |
| 35 | +npx zksync-cli bridge deposit |
| 36 | +``` |
| 37 | + |
| 38 | +### Deposit Options |
| 39 | + |
| 40 | +If options are not specified, you will be prompted to enter them. |
| 41 | + |
| 42 | +- `--to, --recipient <0x address>`: Recipient address on L2. |
| 43 | +- `--amount <0.1>`: Amount to deposit. |
| 44 | +- `--token <0x address>`: ERC-20 token address. |
| 45 | +- `--pk, --private-key <wallet private key>`: Private key of the sender. |
| 46 | +- `--chain <chain>`: Chain to use. |
| 47 | +- `--l1-rpc <URL>`: Override L1 RPC URL. |
| 48 | +- `--rpc <URL>`: Override L2 RPC URL. |
| 49 | + |
| 50 | +### Depositing ERC-20 Tokens |
| 51 | + |
| 52 | +To deposit ERC-20 tokens, include the `--token` option with the token's contract address: |
| 53 | + |
| 54 | +```bash |
| 55 | +npx zksync-cli bridge deposit --token 0x3e622317f8C93f7328350cF0B56d9eD4C620C5d6 |
| 56 | +``` |
| 57 | + |
| 58 | +## Bridge Withdraw |
| 59 | + |
| 60 | +Transfer tokens from L2 back to L1. |
| 61 | + |
| 62 | +```bash |
| 63 | +npx zksync-cli bridge withdraw |
| 64 | +``` |
| 65 | + |
| 66 | +### Withdraw Options |
| 67 | + |
| 68 | +You will be prompted to enter options if they are not specified. |
| 69 | + |
| 70 | +- `--to, --recipient <0x address>`: Recipient address on L1. |
| 71 | +- `--amount <0.1>`: Amount to withdraw. |
| 72 | +- `--token <0x address>`: ERC-20 token address (omit this option to withdraw ETH). |
| 73 | +- `--pk, --private-key <wallet private key>`: Private key of the sender. |
| 74 | +- `--chain <chain>`: Chain to use. |
| 75 | +- `--l1-rpc <URL>`: Override L1 RPC URL. |
| 76 | +- `--rpc <URL>`: Override L2 RPC URL. |
| 77 | + |
| 78 | +### Withdrawing ERC-20 Tokens |
| 79 | + |
| 80 | +For withdrawing ERC-20 tokens, specify the token address using the `--token` option: |
| 81 | + |
| 82 | +```bash |
| 83 | +npx zksync-cli bridge withdraw --token 0x3e622317f8C93f7328350cF0B56d9eD4C620C5d6 |
| 84 | +``` |
| 85 | + |
| 86 | +## Withdraw Finalize |
| 87 | + |
| 88 | +Finalize the withdrawal of funds with the following command. This step is necessary to complete the withdrawal process initiated on L2. |
| 89 | + |
| 90 | +```bash |
| 91 | +npx zksync-cli bridge withdraw-finalize |
| 92 | +``` |
| 93 | + |
| 94 | +### Finalize Withdraw Options |
| 95 | + |
| 96 | +Options will be prompted if not specified. |
| 97 | + |
| 98 | +- `--hash <transaction_hash>`: L2 withdrawal transaction hash to finalize. |
| 99 | +- `--pk, --private-key <wallet private key>`: Private key of the sender. |
| 100 | +- `--chain <chain>`: Chain to use. |
| 101 | +- `--l1-rpc <URL>`: Override L1 RPC URL. |
| 102 | +- `--rpc <URL>`: Override L2 RPC URL. |
| 103 | + |
| 104 | +## Troubleshooting |
| 105 | + |
| 106 | +If you encounter any issues, please consult our [troubleshooting guide](../../zksync-cli/troubleshooting.md) or report them in our [GitHub discussions](https://github.com/zkSync-Community-Hub/zksync-developers/discussions/new?category=general). |
0 commit comments