Can I withdraw the chain transaction only by paying 0.5 yuan? This brings endless trouble to DApp.

In life, fraud is hard to prevent.

The scammers firmly grasp the victim's psychological activities, pretending to be the identity of the public prosecution law to break through the victim's psychological defense line, and then arbitrarily arbitrarily arbitrarily let the victims hand over their own money. When the victims react, the scammers have already escaped. .

As a coping strategy, major banks have given the transfer the next day to the account, the solution that can be withdrawn during the period, giving users room for remorse. This kind of operation is not difficult for a centralized bank, but can it be done in a decentralized blockchain?

At first glance, reversing the transaction on the blockchain is like a fantasy, but the result is ok ! As Mr. Lu Xun said: There is no road in the world, and there are more people to go, and it will become a road.

It is the fact that many users have the need to revoke transactions on the blockchain , so there is a general retraction scheme slowly, but this convenience for the user has brought endless trouble to DApp and DApp developers. .

Did the DApp you developed show users incorrect information? Don't rush to deny it, because it is likely to happen, and it is under the premise that you are completely unaware of it.

Since the beginning of the year, there have been technical teams conducting more than 30 transaction usability audits of mainstream DApps, each of which involved more than 50 customized quantitative indicators and qualitative assessments. Unexpectedly, however, we have not yet encountered which DApp can handle the scenario where the transaction was cancelled. Trading is the top priority of every DApp, but why is this happening?

Before we delve into the impact of cancellations and why most DApps don't address this issue, you need to understand what is cancelled.

What is a cancelled transaction?

In Ethereum, the act of canceling a transaction is to cover the transaction that will be processed with a new transaction. It should be noted that this mechanism for canceling transactions is not an official standard of Ethereum, but a customary convention.

New transactions usually have the following characteristics compared to cancelled transactions:

  • Have an identical random number (nonce),
  • Initiated by the same wallet address,
  • Are sent to an external account (not a smart contract),
  • The fuel cost of the transaction ( Gas ) is at least 10% higher.
  • But the amount of the transaction is 0.
  • This new transaction is signed and submitted by the user before the original transaction is confirmed by the blockchain.

Why does this mechanism work? Since the miners prioritize transactions with higher fuel costs, the miners will deal with the transaction that will be cancelled after the new transaction is confirmed, even if the transaction enters the miners earlier to store unprocessed transactions. Information in the trading pool. In other words, the mechanism for canceling a transaction is a bit like a probabilistic game.

 

How can I cancel a transaction?

 

Most (but not all) Ethereum wallets can help you cancel your trade. For example, in the browser-based plug-in Ethereum light wallet MetaMask, you can cancel a transaction like this : first find the pending transaction, click to display the details of the transaction, and then click "Cancel transaction" " button. The whole operation is as follows:

640

How to cancel a transaction in MetaMask

PENDING (in progress) indicates that the transaction is being processed, click on the transaction details, and the Cancel button indicates cancellation of the transaction. The dialog box that pops up indicates that the cancellation of the transaction requires a fuel cost of $0.08 (approximately RMB 0.5). Clicking on the cancellation transaction here does not guarantee that your original submitted transaction will be 100% cancelled. But if the cancellation is successful, you need to pay the above fuel costs, do you want to try?

Although the function of canceling the transaction may seem a bit wasteful, it turns out to be a necessary tool for users to use Dogues with complex functions, because users in these DApps are used to carefully reviewing their transactions. Proactively manage fuel costs.

[Cancel transaction] Is it so simple and straightforward?

This is not the case!

There is a fatal problem when canceling a deal: your DApp. When a user participates in a DApp that you develop and trades, the user's cancel transaction only occurs between the user and his digital wallet, that is, your DApp is completely uninvolved in this session.

 

How to identify a cancelled transaction?

 

After knowing the characteristics of the cancelled trade, can you find something in the fourth and fifth trades in the chart below?

Cancelled transaction example

In the ideal case, the fifth trade will cover the fourth trade, which means that the fourth trade will be cancelled.

The random numbers for the fourth and fifth transactions are the same, and the fifth transaction:

  • More fuel costs were paid.
  • The amount of the transaction is 0.
  • Has a different timestamp than the previous transaction.
  • Has a different transaction hash than the previous transaction.

The first three are at the heart of the cancellation mechanism, and the fourth is a tricky issue for DApp and DApp developers.

 

How will the cancelled transaction affect the DApp user experience?

Since the original transaction (the cancelled transaction) and the new transaction that covers it later have different hash values, and the DApp you developed is not involved in the creation of this new transaction, your DApp has nothing to do. Ways to get in touch with this new deal.

Normally, your DApp will think that the original transaction is being processed and always show the user the status of the process. This is a bit blunt. Let's use an example to illustrate what this is all about. This is an example of what our team recently discovered when auditing DApp:

The first transaction in the picture has been cancelled

But the DApp doesn't know, or shows it as "in process"

In fact, when the first transaction had been added to the trading pool by the miners, the second transaction was first settled, covering and replacing it.

Since DApp does not have a way to establish contact with the second transaction, DApp will never know if the status of the first transaction was confirmed or failed. Instead, DApp will only show that the first transaction is being processed. in.

With the development of the Ethereum network, the cancellation of transactions has become more and more common. So here we strongly recommend that all DApp developers build front-end features that can handle this situation.

If you are using a DApp that can handle the cancellation of the transaction well, please let us know at the end of the article!

Source | hackernoon

Compilation | Guoxi

Editor | Carol

Produced | Blockchain Base Camp (blockchain_camp)

We will continue to update Blocking; if you have any questions or suggestions, please contact us!

Share:

Was this article helpful?

93 out of 132 found this helpful

Discover more

Market

Blast TVL Shoots to the Moon, Attracting Both Praise and Criticism

Big news for fashion lovers Blast L2's TVL surpasses $570 million after recent launch by Paradigm and Standard Crypto!

Market

Vanguard CEO Shuns Bitcoin ETF, Urges Long-Term Investment The Plot Thickens!

Vanguard CEO Rejects Bitcoin ETF Support, Stresses Firm's Focus on Long-Term Investing Strategy.

Blockchain

Introducing the Crypto Fashion Trend: Tangem Ring

Fashion-forward crypto enthusiasts rejoice! The highly anticipated launch of Tangem Ring, a stylish hardware wallet, ...

Market

BlackRock and VanEck have submitted revised S-1 forms for a bitcoin ETF to address the SEC's recent comments.

The applicants have promptly addressed the SEC's comments on their S-1 forms in order to prepare for a potential appr...

Market

SEC Delays Hashdex and Grayscale: A Comedy of ETF Errors

The SEC postpones decision on Hashdex and Grayscale's Bitcoin and Ether ETFs, citing the need for additional time.

Market

El Salvador’s Bitcoin Wallet Flooded with “Rare Sats” and More!

The El Salvador Bitcoin cold wallet has experienced an influx of diverse ordinals, including Satoshis, Cats, and Sats...