Cancel Pending Transaction

This page introduces how to cancel a pending transaction with Wallet API.

Before Getting Started

  • The x-chain-id value for calling the API is 8217 (Cypress) or 1001 (Baobab).

  • Essential parameters for calling APIs are described in individual examples.

Values that a user needs to enter for calling APIs will be represented with one pair of braces ({}). A user must enter the following values.

Item

Description

Note

chain-id

8217 or 1001

Cypress(Klaytn mainnet) or Baobab(Klaytn testnet

access-key-id

Auth ID

accessKeyId obtained from KAS Console - Security - Credential

secret-access-key

Auth Password

secretAccessKey obtained from KAS Console - Security - Credential

krn

(optional) ID of Account Pool

Unnecessary when using Default Account Pool

A KAS API Authentication Key (API Auth Key) provides access to all KAS services and all the rights to a Klaytn account which was created by calling Wallet API via this API Auth Key. The rights here include accessing and transferring all the assets (KLAY, etc.) of or sending a transaction from a Klaytn account. If you shared your API Auth Key with any unauthorized personnel, your Klaytn account could be compromised and might cause unwanted transaction execution.

DO NOT share your API Auth Key (Secret AccessKey or Authorization) with any unauthorized personnel. DO PUT efforts necessary to keep your API Auth Key safe for the security of your KAS/Klaytn account.

Send Cancel Transaction: Direct Payment of Transaction Fee

Send a transaction for canceling a pending (status = pending) transaction that was sent to Klaytn. For example, the transaction will be pending instead of being executed until all required signatures are obtained if the number of signatures for a transaction sent to Klaytn with a multisig account is lacking. Either a nonce or a transaction hash is required to cancel a transaction. For details about canceling transaction, please visit here.

To send the cancelation transaction, the user has to send a transaction to Klaytn Node and pay the transaction fee. To call the API, he/she must create an Account Pool and account, and then select an account to use. In this example, the sending account must directly pay the transaction fee for sending the cancelation transaction.

For details about KAS SDK (caver-js/caver-java extensions) installation and execution, please visit KAS SDK. For more details on creating an Account Pool, account, and selecting an account, refer to Getting Started.

API Request

Call the cancelation transaction transmission API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

curl --location --request DELETE "https://wallet-api.klaytnapi.com/v2/tx" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \
--header "Content-Type: application/json" \
--data-raw "{
    "from": "0x5bb85d4032354E88020595AFAFC081C24098202e",
    "transactionHash": "0x02e13becf638cac359381fa5dfc3ef8f598a90cceb9842eb714019bcd883fd59",
    "nonce": 0,
    "gasLimit": 1000000,
    "submit": true
}"
  • submit: If it is false, a transaction is not sent and the RLP of signed transaction and the transaction information are returned.

API Response

Here is a response of the cancelation transaction transmission API.

{
  "from": "0xa4068f0d4e4ffad5945824cddd748ba2dc450330",
  "gasLimit": 1000000,
  "gasPrice": "0x5d21dba00",
  "nonce": 99,
  "rlp": "0x38f869638505d21dba00830f424094a4068f0d4e4ffad5945824cddd748ba2dc450330f847f8458207f6a0df27642d09a731cb4002b3536db364821a2c25a1104e79d2295916c3368f6975a00db6df75befe463ca2da855e90b8389c41730cfe7773851e7391ab6431804852",
  "signatures": [
    {
      "R": "0xdf27642d09a731cb4002b3536db364821a2c25a1104e79d2295916c3368f6975",
      "S": "0xdb6df75befe463ca2da855e90b8389c41730cfe7773851e7391ab6431804852",
      "V": "0x7f6"
    }
  ],
  "status": "Submitted",
  "transactionHash": "0x665824b0c9cd2c8a76ac0fdb007f424f013d9c3e49723e2c8c896f38e7990375",
  "typeInt": 56
}

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developer forum.

Send Cancel Transaction: Transaction Fee Delegation by User

Send a transaction for canceling a pending (status = pending) transaction that was sent to Klaytn. For example, the transaction will be pending instead of being executed until all required signatures are obtained if the number of signatures for a transaction sent to Klaytn with a multisig account is lacking. Either a nonce or a transaction hash is required to cancel a transaction. For details about canceling transaction, please visit here.

To send the cancelation transaction, the user has to send a transaction to Klaytn Node and pay the transaction fee. To call this API, you first need to create the Klaytn account who sends this transaction and the Klaytn account who pays the transaction fee (fee-payer) in Account Pool and Fee Payer Account Pool, each. In this example, the fee payer account pays the transaction transmission fee, not the account who sends this transaction. For details about fee-delegation methods that KAS provides for you, please visit here.

For details about KAS SDK (caver-js/caver-java extensions) installation and execution, please visit KAS SDK. For more details on creating an Account Pool, account, and selecting an account, refer to Getting Started. For more details on creating an fee payer Account Pool, fee payer account, and selecting an fee payer account, refer to Getting Started.

API Request

Call the cancelation transaction transmission with fee-delegation API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

curl --location --request DELETE "https://wallet-api.klaytnapi.com/v2/tx/fd-user" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \
--header "Content-Type: application/json" \
--data-raw "{
  "from": "0x5bb85d4032354E88020595AFAFC081C24098202e",
  "transactionHash": "0x02e13becf638cac359381fa5dfc3ef8f598a90cceb9842eb714019bcd883fd59",
  "nonce": 0,
  "gasLimit": 1000000,
  "submit": true,
  "feePayer": "0x85B98485444c89880cD9C48807CEF727C296F2da",
  "feeRatio": 10
}"
  • submit: If it is false, a transaction is not sent and the RLP of signed transaction and the transaction information are returned.

  • fee_payer: If a user uses a separate transaction fee-payer account, he/she provides the account address to this parameter. Do not use the "feePayer" parameter to make KAS pay for the transaction fee first.

  • feeRatio: The ratio (1%~99%) of the transaction fee that a feePayer pays. The remaining fees will be directly paid by the account (from) that sends transactions to Klaytn.

    • This parameter is available for fee delegation through either a user fee-payer account or and KAS (KAS Global fee payer)

API Response

Here is a response of the cancelation transaction transmission API with fee-delegation.

{
  "feePayer": "0xe8ab1729ab614551021cf5cc22c0e037f5a82930",
  "from": "0x9c56b45b7443bc73f47234199982481c64807f78",
  "gasLimit": 1000000,
  "gasPrice": "0x5d21dba00",
  "nonce": 330,
  "rlp": "0x39f8c982014a8505d21dba00830f4240949c56b45b7443bc73f47234199982481c64807f78f847f8458207f5a061ffd0e76da83a4c4b05ca23d8cd66ac4b6c5a63183b6cc89ac3b12e9688aeb8a052edf81652ff174e3a0e3856a35ee71ea814c70fbc9fb18f8c66adeb15d0550394e8ab1729ab614551021cf5cc22c0e037f5a82930f847f8458207f5a05a5bf47cbc87b1091ebfa140c504b3d7ab1756cdc1e25ea168a277e478a5e01da00f8bfdbad9f94507e53c3abfa6d9e824170939b47731483bc629d3d58326bbb9",
  "signatures": [
    {
      "R": "0x61ffd0e76da83a4c4b05ca23d8cd66ac4b6c5a63183b6cc89ac3b12e9688aeb8",
      "S": "0x52edf81652ff174e3a0e3856a35ee71ea814c70fbc9fb18f8c66adeb15d05503",
      "V": "0x7f5"
    }
  ],
  "status": "Submitted",
  "transactionHash": "0x176a40a522123e831107430e321adc34397f767ec9f75080ad0464ac0757be27",
  "typeInt": 57
}

“typeInt” variable is a value for identifying the transaction type. For details about the types of transactions, please visit here.

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developer forum.

Send Cancel Transaction: Transaction Fee Delegation by KAS

Send a transaction for canceling a pending (status = pending) transaction that was sent to Klaytn. For example, the transaction will be pending instead of being executed until all required signatures are obtained if the number of signatures for a transaction sent to Klaytn with a multisig account is lacking. Either a nonce or a transaction hash is required to cancel a transaction. For details about canceling transaction, please visit here.

To send the cancelation transaction, the user has to send a transaction to Klaytn Node and pay the transaction fee. To call this API, you first need to create an Account Pool and a Klaytn account who sends this transaction in that Account Pool. In this example, the KAS global fee payer account pays the transaction transmission fee, not the account who sends this transaction. This fee paid by KAS global fee payer instead of the Klaytn account who sent a transaction will later be charged to your KAS account. For details about fee-delegation methods that KAS provides for you, please visit here.

For details about KAS SDK (caver-js/caver-java extensions) installation and execution, please visit KAS SDK. For more details on creating an Account Pool, account, and selecting an account, refer to Getting Started.

API Request

Call the cancelation transaction transmission with KAS GlobalFeePayer fee-delegation API. You may use the REST API or KAS SDKs (caver-js, caver-java extensions) for this.

curl --location --request DELETE "https://wallet-api.klaytnapi.com/v2/tx/fd" \
-u {access-key-id}:{secret-access-key} \
--header "x-chain-id: {chain-id}" \
--header "Content-Type: application/json" \
--data-raw "{
  "from": "0x5bb85d4032354E88020595AFAFC081C24098202e",
  "transactionHash": "0x02e13becf638cac359381fa5dfc3ef8f598a90cceb9842eb714019bcd883fd59",
  "nonce": 0,
  "gasLimit": 1000000,
  "submit": true,
  "feeRatio": 10
}"
  • submit: If it is false, a transaction is not sent and the RLP of signed transaction and the transaction information are returned.

  • feeRatio: The ratio (1%~99%) of the transaction fee that a feePayer pays. The remaining fees will be directly paid by the account (from) that sends transactions to Klaytn.

    • This parameter is available for fee delegation through either a user fee-payer account or and KAS (KAS Global fee payer)

API Response

Here is a response of the cancelation transaction transmission API with KAS GlobalFeePayer fee-delegation.

{
  "feePayer": "0x85b98485444c89880cd9c48807cef727c296f2da",
  "feeRatio": 10,
  "from": "0x9c56b45b7443bc73f47234199982481c64807f78",
  "gasLimit": 1000000,
  "gasPrice": "0x5d21dba00",
  "nonce": 330,
  "rlp": "0x39f8c982014a8505d21dba00830f4240949c56b45b7443bc73f47234199982481c64807f78f847f8458207f5a061ffd0e76da83a4c4b05ca23d8cd66ac4b6c5a63183b6cc89ac3b12e9688aeb8a052edf81652ff174e3a0e3856a35ee71ea814c70fbc9fb18f8c66adeb15d0550394e8ab1729ab614551021cf5cc22c0e037f5a82930f847f8458207f5a05a5bf47cbc87b1091ebfa140c504b3d7ab1756cdc1e25ea168a277e478a5e01da00f8bfdbad9f94507e53c3abfa6d9e824170939b47731483bc629d3d58326bbb9",
  "signatures": [
    {
      "R": "0x61ffd0e76da83a4c4b05ca23d8cd66ac4b6c5a63183b6cc89ac3b12e9688aeb8",
      "S": "0x52edf81652ff174e3a0e3856a35ee71ea814c70fbc9fb18f8c66adeb15d05503",
      "V": "0x7f5"
    }
  ],
  "status": "Submitted",
  "transactionHash": "0x176a40a522123e831107430e321adc34397f767ec9f75080ad0464ac0757be27",
  "typeInt": 57
}

“typeInt” variable is a value for identifying the transaction type. For details about the types of transactions, please visit here.

For details about this API, please visit here. For inquires about this document or KAS, please visit KAS Developer forum.

Last updated