Wallet Module in ZKsync Ecosystem

ยท

The Wallet module provides functionalities for integrating, creating, and managing wallets within the ZKsync ecosystem.

Key Functions and Methods

approveERC20

Bridging ERC20 tokens from Ethereum requires approving the tokens to the ZKsync Ethereum smart contract.

Inputs

ParameterTypeDescription
tokenAddressEthereum address of the token
amountBigNumberishAmount of token to be approved
overrides?ethers.Overrides?Transaction overrides

Example

import { Wallet, Provider, utils } from "zksync-ethers";
import { ethers } from "ethers";

const PRIVATE_KEY = "YOUR_PRIVATE_KEY";
const provider = Provider.getDefaultProvider(types.Network.Sepolia);
const ethProvider = ethers.getDefaultProvider("sepolia");
const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider);

const tokenL1 = "0x56E69Fa1BB0d1402c89E3A4E3417882DeA6B14Be";
const txHandle = await wallet.approveERC20(tokenL1, "10000000");
await txHandle.wait();

claimFailedDeposit

Withdraws funds from a failed deposit initiated on L2.

Inputs

ParameterTypeDescription
depositHashbytes32L2 transaction hash of failed deposit

Example

const FAILED_DEPOSIT_HASH = "YOUR_TX_HASH";
const claimFailedDepositHandle = await wallet.claimFailedDeposit(FAILED_DEPOSIT_HASH);

connect

Connects Wallet object to ZKsync network Provider.

Example

const unconnectedWallet = new Wallet(PRIVATE_KEY);
const wallet = unconnectedWallet.connect(provider);

deposit

Transfers tokens from L1 to L2 network.

Example

const depositTx = await wallet.deposit({
  token: utils.ETH_ADDRESS,
  amount: 10_000_000
});
await depositTx.wait();

Frequently Asked Questions

What is the Wallet module in ZKsync?

The Wallet module provides tools for creating and managing wallets within the ZKsync ecosystem, enabling interaction with both L1 and L2 networks.

How do I approve tokens for bridging?

Use the approveERC20 method to approve tokens before bridging them from Ethereum to ZKsync.

What happens if my deposit fails?

You can use claimFailedDeposit to recover funds from failed deposits.

๐Ÿ‘‰ Learn more about ZKsync wallets

Additional Features

The Wallet module supports all standard Ethereum wallet operations while adding ZKsync-specific functionality for seamless cross-layer interactions.

๐Ÿ‘‰ Explore advanced wallet features

Remember to always prioritize security when handling wallet operations and private keys.


This content has been:
1. Organized with clear headings and subheadings
2. Structured with Markdown formatting
3. Optimized for SEO with natural keyword integration
4. Polished for readability and engagement
5. Includes FAQ and anchor text sections as specified
6. Maintains original meaning while improving clarity