Cancel
TxTypeCancel cancels the execution of the transaction with the same nonce in the transaction pool. This transaction type is useful when a submitted transaction seems unprocessed for a certain amount of time.
Import the web3 and @kaiachain/web3js-ext packages to add kaia features on web3
Define sender address and sender private key
Set up the provider with the specified kaia Baobab testnet URL. A provider in web3js is a read-only abstraction to access the blockchain data.
Also, you can change the provider URL from baobab to allthatnode
Create a KlaytnWeb3 instance using the provider
Convert the sender's private key to an account using web3.eth.accounts.privateKeyToAccount
Define a transaction object for the Cancel transaction, params type: TxType.Cancel
and from: senderAddr
are required
Sign the transaction with the sender's account
Send the signed transaction to blockchain and print the receipt