# Cancel a Check This tutorial shows how to cancel a [Check](/docs/concepts/payment-types/checks), which removes the [Check entry](/docs/references/protocol/ledger-data/ledger-entry-types/check) from the ledger without sending money. You may want to cancel an incoming Check if you do not want it. You might cancel an outgoing Check if you made a mistake when sending it or if circumstances have changed. If a Check expires, it's also necessary to cancel it to remove it from the ledger so the sender gets their [owner reserve](/docs/concepts/accounts/reserves#owner-reserves) back. ## Prerequisites - You should be familiar with the basics of using the [xrpl.js client library](/docs/tutorials/javascript/build-apps/get-started). - You need an XRP Ledger account including its secret key. (You can get one on Testnet for free.) See also: [XRP Faucets](/resources/dev-tools/xrp-faucets). - You need the ID of a Check ledger entry that you are either the sender or recipient of. See also: [Send a Check](/docs/tutorials/how-tos/use-specialized-payment-types/use-checks/send-a-check). ## Source Code The complete source code for this tutorial is available in the source repository for this website: Checks sample code ## Steps ### 1. Prepare the CheckCancel transaction Figure out the values of the [CheckCancel transaction](/docs/references/protocol/transactions/types/checkcancel) fields. The following fields are the bare minimum; everything else is either optional or can be [auto-filled](/docs/references/protocol/transactions/common-fields#auto-fillable-fields) when signing: | Field | Value | Description | | --- | --- | --- | | `TransactionType` | String | Use the string `CheckCancel` when canceling a Check. | | `Account` | String (Address) | The address of the sender who is canceling the Check. (In other words, your address.) | | `CheckID` | String | The ID of the Check entry to cancel. You can get this information when you [send a check](/docs/tutorials/how-tos/use-specialized-payment-types/use-checks/send-a-check), or by [looking up checks](/docs/tutorials/how-tos/use-specialized-payment-types/use-checks/look-up-checks). | For example: // Prepare the transaction ------------------------------------------------ const checkcancel = { "TransactionType": "CheckCancel", "Account": wallet.address, "CheckID": check_id }; ### 2. Submit the CheckCancel transaction Submit the CheckCancel transaction in the usual way and wait for it to be validated. If the result code is `tesSUCCESS` and the transaction is in a validated ledger, the transaction is successful. For example: // Submit the transaction ------------------------------------------------- const tx = await client.submitAndWait( checkcancel, { autofill: true, wallet: wallet } ) ## 3. Confirm transaction result If the transaction succeeded, it should have a `"TransactionResult": "tesSUCCESS"` field in the metadata, and the field `"validated": true` in the result, indicating that this result is final. For example: // Confirm results -------------------------------------------------------- console.log(`Transaction result: ${JSON.stringify(tx, null, 2)}`) if (tx.result.meta.TransactionResult === "tesSUCCESS") { // submitAndWait() only returns when the transaction's outcome is final, // so you don't also have to check for validated: true. console.log("Transaction was successful.") } The `submitAndWait()` method in xrpl.js only returns when the transaction's result is final, so you can assume that the transaction is validated if it returns a result code of `tesSUCCESS`.