claimFailedDeposit
Withdraws funds from the initiated deposit, which failed when finalizing on L2.
If the deposit L2 transaction has failed, it sends an L1 transaction calling claimFailedDeposit
method of the
L1 bridge, which results in returning L1 tokens back to the depositor.
Usage
example.ts
import { account, walletClient, zksyncClient } from './config'
import { legacyEthAddress } from 'viem/zksync'
const hash = await walletClient.claimFailedDeposit({
account,
client: zksyncClient,
depositHash: '<L2_HASH_OF_FAILED_DEPOSIT>'
})
Account Hoisting
If you do not wish to pass an account
to every claimFailedDeposit
, you can also hoist the Account on the Wallet Client (see config.ts
).
example.ts
import { walletClient, zksyncClient } from './config'
import { legacyEthAddress } from 'viem/zksync'
const hash = await walletClient.claimFailedDeposit({
client: zksyncClient,
depositHash: '<L2_HASH_OF_FAILED_DEPOSIT>'
})
Returns
The Transaction hash.
Parameters
client
- Type:
Client
The L2 client for fetching data from L2 chain.
const hash = await walletClient.claimFailedDeposit({
client: zksyncClient,
depositHash: '<L2_HASH_OF_FAILED_DEPOSIT>'
})
depositHash
- Type:
Hash
The L2 transaction hash of the failed deposit.
const hash = await walletClient.claimFailedDeposit({
client: zksyncClient,
depositHash: '<L2_HASH_OF_FAILED_DEPOSIT>',
})
chain (optional)
- Type:
Chain
- Default:
walletClient.chain
The target chain. If there is a mismatch between the wallet's current chain & the target chain, an error will be thrown.
import { zksync } from 'viem/chains'
const hash = await walletClient.claimFailedDeposit({
chain: zksync,
client: zksyncClient,
depositHash: '<L2_HASH_OF_FAILED_DEPOSIT>'
})