As we all know, bitcoin works like a ledger whose updates or insertions are approved between the participating nodes in the block chain (how it works). This allows us to see the chain of blocks in real time and analyze this chain backwards.
In this application, only the forward block chain will be analyzed. This decision was made because the software is conceived as a toy application to exemplify the use of a technology (redis stack) and not as a final product.
The application will analyze the blockchain, the interactions between wallets and the price of bitcoin in real time. This will be done getting data of the following APIs:
Project that queries BTC chain and discover interactions between wallets, trending wallets.
Architecture
Dashboard
Wallet detail
Overview video (Optional)
Here's a short video that explains the project and how it uses Redis:
[Insert your own video here, and remove the one below]
How it works
The application has as its central point the redis stack.
Two nodes (market and chain) provide information through the pub/sub and the redis cache
Graph, stats, stream and topk simply process what comes through the pub/sub, update the information in redis and expose it through an API.
Graph maintains a database where each node is a wallet and the edges are the transactions between wallets.
Stats maintains the information related to quotes and the number of transactions per minute and btc per minute.
Topk maintains a list of the wallets that appear the most on the blockchain I'm sending and…
Here we will comment on the functions of the services that ingest data and those entered in our system.
Market
Checks the kraken.com API periodically updates the price of btc in euros and dollars.
Update that price in the redis cache and post an event to let you know that price has been updated.
Outputs:Redis commands
Redis cache set market:cache:USD, market:cache:EUR.
Redis publish market:update
SET market:cache:USD {...}
PUBLISH market:update {....}
We can check cache value stored with redis insight:
Chain
Connects to the blochain.com websocket to retrieve bitcoin transactions
At this point a technical decision was made, being an example of a toy, we filter transactions less than one bitcoin so as not to have storage problems in the development of the app.
For each transaction, it calculates its value in eur/usd (consulting the cache) and publishes an event with the transaction information and the value in FIAT currency.
Outputs:Redis commands
Redis publish transactions:new
PUBLISH transactions:new "{...}"
Data processing
These nodes listen for events from the ingest nodes and process the information that comes to them. Each node is responsible for specific processing and exposing the data through an API.
Graph (Graph redis)
The responsibility of this node is to see the transactions between wallets, for this we use the redis graph database, so for each transaction we will create a node (if it does not exist) for the sender and receiver of the transaction, we will also create an edge with the transaction value.
With the following query we can see all nodes on the redis graph database.
TopK (TopK redis)
The responsibility of this node is to have a list with the top of the wallets that appear the most to see the wallets with the most activity (both sending and receiving btc), which should give us a list with wallets from SCAMs, exchanges... etc.