🟧
JS SDK Stuck Transaction
Any cross-chain swap consists of two transactions:
  1. 1.
    One transaction (signed and sent by a user) is on the origin blockchain and
  2. 2.
    Another transaction (signed and sent by relayers) is on the destination blockchain.
A stuck transaction (or a stuck trade/stuck cross-chain swap) means that the transaction on the origin blockchain has been processed, but there is no transaction on the destination blockchain, or that transaction is failed.
For the user, a stuck trade means that they give away tokens on the origin blockchain and get nothing on the destination blockchain.
A cross-chain swap 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 swap. A stuck cross-chain swap can be reverted.
If you are looking for more details on what happens during reverting of stuck transactions, please refer to this article: Emergencies (stuck transactions)​
Dealing with stuck transactions consists of two steps:
  • Find a stuck transaction,
  • Revert the stuck transaction.

Getting Stuck Transactions

To find stuck transactions for a specified address, please use getPendingRequest:
1
const pendingRequests = await symbiosis.getPendingRequests(
2
address
3
)
Copied!
The getPendingRequest method returns a list of objects of PendingRequest type, where revertableAddress equals the specified address.

Reverting Stuck Transactions

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:
1
const revertPending = symbiosis.newRevertPending(request: PendingRequest)
2
​
3
const { fee, execute } = await revertPending.revert()
4
​
5
const { waitForMined } = await execute(signer)
6
​
7
const { receipt, waitForComplete } = await waitForMined()
8
​
9
const log = await waitForComplete()
Copied!
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
An instance of TransactionRequest type, used in the stateless mode.
Calling the execute function returns:
  • An object response of TransactionResponse type​
  • A function waitForMined is a function of waiting for the transaction to be mined.
Calling the waitForMined function returns:
  • An object receipt of TransactionReceipt type​
  • A function waitForComplete is a function of waiting for getting tokens on the destination blockchain.
The stateless mode (since JS SDK v2.3)
1
const revertPending = symbiosis.newRevertPending(request)
2
​
3
// transactionRequest contains everything you need to send a transaction by yourself
4
const { transactionRequest } = await revertPending.revert()
5
​
6
... // Send transaction
7
​
8
// Wait for the transaction to be completed on the destination chain
9
const log = await revertPending.waitForComplete()
Copied!