SDK
Javascript
How to
Wallet Operation
Cancel Transaction

Cancel Transaction

This method allows you to cancel a transaction from a blockchain network.

Method Signature

async cancelTransaction(config: CancelTransactionConfig): Promise<string>

Parameters

  • config: CancelTransactionConfig - An object containing the following properties:
    • network (required): Network - The network used for transactions. You can use the Network enum to specify the network.
    • nonce (required): number - A unique number for each transaction. Provide the nonce of the transaction you want to cancel.

Returns

Promise<string> - The hash of the canceled transaction.

Example Usage

const hash = await sdk.wallet.cancelTransaction({
  network: Network.ETHEREUM,
  nonce: 1234567890,
});
console.log(hash);

Response Example

"0x4ec81ca3d6a112bdf991a220ed83458f061f1f818273c93546ea91a4e1d675"
ℹ️

The response is a string representing the transaction hash of the cancellation transaction.

⚠️

Make sure you provide the correct nonce of the transaction you want to cancel. Canceling a transaction with an incorrect nonce may result in unexpected behavior.

Additional Information

  • The cancellation is initiated by sending a new transaction with the same nonce as the original transaction, but with a higher gas price to prioritize it over the original transaction.
  • The success of the cancellation depends on whether the new transaction is mined before the original one.
  • This method requires a valid wallet token in the SDK configuration.

For more information, see the Xellar Cancel Transaction API Documentation (opens in a new tab).