- If the records on a blockchain like Ethereum are immutable, how is it possible to modify or cancel a transaction on the Ethereum blockchain?
- Transactions in Ethereum go through a series of stages and it is specifically in one of them where it is possible to cancel or modify it.
- When transactions are in the “pending state” process or Mempool, which is the place where all valid transactions wait to be confirmed, they are at a time when they can be modified.
When you enter the crypto world there is a rule that almost makes you tattoo it: “when you make a crypto transaction there is no going back”. It is for this reason that users are strongly encouraged to be careful to place their crypto address correctly and verify that their wallet accepts that asset, otherwise they can lose all their money.
In the worst case scenario, if they fall victim to a scam, it will be almost impossible for them to get a refund on their assets, but…if we told you that there is a way to modify or cancel a transaction?
There are many reasons why a person might want to modify or reverse a transaction. However, to do so, it is necessary to understand how a blockchain works as it is an important step to take before starting to operate in the world of cryptocurrencies.
How does a blockchain work?
Blockchain is an open and distributed ledger, these being its fundamental characteristics. But, additionally, it uses a data structure such that only data can be added; that is, it is not possible to erase the previous data.
It is precisely for this reason that the blockchain represents a verifiable and immutable record of data.
Nowwhen a transaction is made between two or more parties, it must be recorded in the blockchain and, for this, a consensus mechanism and a reward system are necessary. Thanks to this, the transactions that are executed can be verified and accepted as true by the entire network.
In this way, once a transaction has been registered in the blockchain, it cannot be modified. So how is it going to be possible to modify or cancel a transaction on the Ethereum blockchain? The reason is the existence of the Mempool and to understand it, it is necessary to explore how transactions work on the Ethereum blockchain.
How is a transaction executed on the Ethereum blockchain?
In any blockchain, a transaction is a series of instructions that have been cryptographically signed by the parties involved. Regular transactions, that is, those where there is a receiver, in Ethereum contain the following information:
- Sender identifier
- receiving address
- The amount of ETH involved in the transaction.
- Transaction Fee Information
- An optional information field.
A particularly relevant concept has to do with the gas fee, being that fee that must be paid for the transactions to be validated, and why do you have to pay a fee? Well, because, as mentioned above, for a transaction to be executed and recorded on the network, the presence of validators is necessary and, for this, a reward system is required for their work. Namely, validators verify the transaction and receive the fees in return.
But why is this reward system necessary? Basically, the obligation of users to pay a fee protects the network from careless or malicious computational tasks, for example, sending spam and unnecessarily congesting the network.
In the case of Ethereum, using a Proof of Work (PoW) consensus mechanism, at least until now, requires miners who will give priority to transactions that pay a higher gas fee. Therefore, transactions with a low gas rate are at the bottom of the queue.
It is precisely for this reason that gas fees on the Ethereum network have risen for the past few years. More activity on the network translates into more transactions to verify, leading to longer waiting times that people seek to reduce by offering miners a higher fee.
Verification process
Transactions in Ethereum go through a series of stages and it is specifically in one of them where it is possible to cancel or modify it.
- Unknown status: At this time the transaction has not been viewed or processed
- Pending status: This is where the Mempool concept comes in, which is the place where all valid transactions wait to be confirmed by the network. When transactions are sent to the Ethereum blockchain, they enter the Mempool, that is, a set of pending transactions. The transaction will remain there until a miner proceeds to verify it. Those transactions with low gas rates will remain longer in this state.
- Status verified and registered: A transaction reaches this state once a miner has selected it from the mempool, verified it, and mined it into a block.
Therefore, the The only phase in which a person can modify or cancel a transaction in the Ethereum network will be when it is pending, that is, in the mempool.
How to cancel a transaction?
A person might want to cancel a transaction for a variety of reasons, such as making a mistake and sending ETH to the wrong address, or because the transaction has been waiting too long.
But in any case, It will be necessary for the transaction to continue in the pending state and, to verify if it is so, it will be necessary to:
- Go to an Ethereum block explorer.
- Paste the hash of the transaction, or ID, into the browser.
- If the browser indicates that the transaction is “pending”, then users will be able to cancel it.
Then people will be able to cancel a pending transaction through two ways: Cancellation in the application and setting a nonce.
- Cancellation in the application: It consists of closing the Ethereum wallet application from where the transaction has been sent and re-logging in. There are even wallets like Metamask that include an automatic transaction cancellation button.
- Configuring a custom nonce: In case the first option does not work, this would be the next one to try. It starts with understanding that a “Nonce” refers to a “Number that is only used once” and is the total number of confirmed transactions sent from the given Ethereum address. Setting up a custom nonce involves the following steps:
- Create a new Ethereum transaction to send 0 ETH to yourself.
- For this new transaction, the gas rate must be increased by at least 10% compared to the previously used rate.
- Replace the nonce of the transaction with the nonce of the original pending transaction.
- By having a higher gas rate than the previous one, the 0 ETH transaction will be executed first. While the previous pending transaction will be canceled because the Blockchain will reject it since the nonce is unique for each transaction.
- Watch out! Fees will be charged even when the transaction is cancelled.
How to unblock a transaction on the Ethereum network?
Since the fundamental reason why a transaction remains pending is the low gas fee, the solution is precisely to increase it for Ethereum miners to take.
In fact, an interesting fact is that the network will not confirm any new transaction from the same wallet address until the first one sent is confirmed.
Some wallets have the automated option to speed up the transaction. Otherwise, you can follow the steps below:
- Create a new transaction with exactly the same specifications as the stuck transaction.
- Go to the advanced options and increase the gas rate.
- Change the nonce of the new transaction to the nonce of the pending transaction.
final thoughts
It is not always necessary to execute an action for a transaction to advance from the pending phase. Sometimes transactions that are stuck in this phase will be verified when network fees drop. However, this can take time.
Therefore, in that case, people can speed up the transaction by increasing the gas fees to be paid, or even cancel it.
Yes, once a person originates a transaction they will have a certain gap where they can simply cancel and prevent this from happening. This is particularly important for those who make a mistake in the amount of cryptocurrency to be sent or the address to which it will be sent.
However, the time gap is critical because, once verified, there is no one in the world who can reverse it and of course the gap will depend on network activity and gas fees entered.
You might be interested in: