DIY block scanner (Blockchain explorer): Why is it needed?

DIY block scanner (Blockchain explorer): Why is it needed?

When developing a crypto wallet, you will encounter a number of problems that are not obvious. We will not consider now the problems associated with generating addresses, signing transactions and other issues that may come to mind first.

Let's focus on a simple and trivial task at first glance - obtaining a list of transactions associated with a specific address. At first glance, this simple request should not raise any questions - after all, the blockchain contains a large database of transactions, right?


Not really. If Bitcoin and its successors (Litecoin, DASH, Docgecoin, etc) are indeed, by definition, a transaction ledger, then Ethereum and its derivatives are already balance ledgers, although they should also store transactions, at least in theory. 


But what’s interesting is that even for a Bitcoin address you will not be able to obtain a complete list of transactions associated with a specific address using standard means, only the inputs (received by the transaction address). With Ethereum everything is even more interesting. Geth (go-ethereum) does not allow regular means to receive transactions at all. If you know the hash of the transaction - no problem, if not - then all you can find out about the address in the blockchain is its balance. 

Of course, this won’t be a big problem if all the addresses are generated by your application, and your backend is already monitoring the state of the mempool and scanning all new blocks for the necessary transactions - you will probably carefully note down all the transactions, put them in the database and have access to them at any time. In the case of Etherem and other blockchains where the token mechanism is implemented similar to the ERC20 standard, you will also receive all transactions associated with smart contract calls (for example, sending or receiving ERC20 tokens). However, almost any good wallet application allows you to import keys and access addresses created in another program. Yes, you can use the approach that the creators of Exodus took - simply “sweep” all the funds from the imported address to the one specified in the application, and then consider the problem closed. 

But how then does the popular Metamask work? How does it manage to show all transactions even for imported addresses? 

Actually, they do not use any special magic. To experiment, try adding a new network to MetaMask, and carefully study the fields that need to be filled in.. Among the obvious data, such as the access point URL, networkID, network name and currency symbol, you will be asked to fill in an optional field - indicate a link to blockexplorer. All information is obtained via API from services such as infura.io and alchemy.com. For Bitcoin, similar functionality is provided by blockhain.com/blockhain.info; a large number of networks are covered by the blockchair service.

It turns out that in order to provide our application with information, it is enough to connect to some such provider and it’s all in the bag? On the one hand, yes. However, such a solution will not always be without drawbacks, and sometimes these drawbacks can be critical. Let's go through only the most obvious ones.

Firstly, you can immediately forget about any confidentiality of operations. A large company will have access to all the data of all your clients and it is not known for what purposes it will use this data. It would be good if it was just a harmless collection of bigdata for market analysis and obtaining insider information when trading. But in the future, such data may become the property of, so to speak, not entirely clean people. By the way, quite recently Alchemy announced that it would register the IPs from which the transaction was made. If they officially announced that they will collect location data not even of their clients, but of clients of all services that use their API, then we can highly assume that they are already actively doing this. 

The second aspect, no less problematic in the future, is that dependence on someone else’s service cannot guarantee that the terms of service will not change. For example, a service will decide to introduce a subscription fee for the API - and the author of any application, even a free one, will be forced to think about what to do about it. Abandon the application? Make it paid? But let me remind you that a crypto wallet is a storage of cryptocurrency, and users of such an application may suddenly lose access to their savings. And the amounts can be significant.

This list can be continued for a long time, but there will be one conclusion - in many cases it is much more rational to provide your own backend and deploy your own infrastructure that will allow you to access the necessary data.

What is needed for this and how to implement it - we will look at it in the next article

You May Also Like

52024-05-30

History of the Bank of England

We continue publications about the banks of the world and the history of banking

Banks, Education,
392018-03-26

Depth of Depth as an analysis tool

In their analytical articles, financial experts quite often operate with the concept of “Exchange Book” or “Dom of Deals”. These reviews often use terms such as “market depth”, “wall” or jargon such as “offers”, “prints”, “icebergs”. Those who are familiar with this stock exchange slang and actively apply it in practice can move on to our next news article. This publication is addressed to those who have come across these concepts, but still have not found t...

Education

Latest articles from Education category