🟧
JS SDK Stuck Transaction
Symbiosis JS SDK Stuck Transaction
Any cross-chain operation (a cross-chain swap, a cross-chain zap, interchain communicating, bridging) consists of two transactions:
- 1.One transaction (signed and sent by a user) is on the source blockchain, and
- 2.Another transaction (signed and sent by relayers) is on the destination blockchain.
A stuck transaction (or a stuck cross-chain operation) means that the transaction on the source blockchain has been processed, but there is no transaction on the destination blockchain, or that transaction is failed.
For the user, a stuck operation means that they give away tokens on the source blockchain and get nothing on the destination blockchain.
A cross-chain operation may get stuck due to multiple reasons. In any case, such a situation is an emergency, and users should be able to deal with it.
There is no way to accomplish a stuck cross-chain operation (somehow to push it). Instead, a stuck cross-chain operation can be reverted.
If you are looking for more details on what happens during reverting of stuck transactions, please refer to this document Emergencies
Dealing with stuck transactions consists of two steps:
- Find a stuck transaction,
- Revert the stuck transaction.
To find stuck transactions for a specified address, please use
getPendingRequest:
const pendingRequests = await symbiosis.getPendingRequests(
address
)
The getPendingRequest
method returns a list of objects of PendingRequest
type, where revertableAddress
equals the specified address.If the
symbiosis.getPendingRequests
method returned a non-empty list of objects of PendingRequest type
, then for every object from the list, you can revert the operation with the revert
method:const revertPending = symbiosis.newRevertPending(request: PendingRequest)
const { fee, execute } = await revertPending.revert()
const { waitForMined } = await execute(signer)
const { receipt, waitForComplete } = await waitForMined()
const log = await waitForComplete()
The
revert
method returns:Property | Description |
---|---|
execute | A function to execute the reverting operation. Calling this function triggers the transaction signing and sends the signed transaction to the blockchain |
fee | An object of TokenAmount type. The amount of tokens to pay the fee for the bridging: the fee for relayers network work. Please refer to the document for more information on relayers. |
transactionRequest |
Calling the
execute
function returns: - A function
waitForMined
is a function of waiting for the transaction to be mined.
Calling the
waitForMined
function returns: - A function
waitForComplete
is a function of waiting for getting tokens on the destination blockchain.
The stateless mode (since JS SDK v2.3)
const revertPending = symbiosis.newRevertPending(request)
// transactionRequest contains everything you need to send a transaction by yourself
const { transactionRequest } = await revertPending.revert()
... // Send transaction
// Wait for the transaction to be completed on the destination chain
const log = await revertPending.waitForComplete()
Last modified 3mo ago