Our first case study focusses on a basic view of the Bitcoin blockchain containing no external data.

The documents in the resulting collection represent transactions, and they include:
(i) the transaction hash;
(ii) the hash of the enclosing block;
(iii) the date in which the block was appended to the blockchain;
(iv) the list of transaction inputs and outputs.

In this use case we analyse the usage of the Bitcoin blockchain as a distributed storage.

Actually, besides being used as a cryptocurrency, Bitcoin allows for
appending a few bytes of metadata to transaction outputs.
This is done preeminently through the OP_RETURN operator of the Bitcoin scripting language.
Several protocols exploit this feature to implement blockchain-based applications,
like e.g. digital assets and notarization services.
These protocols usually mark their transactions by pre-pending an identifier to each piece of metadata.
Hence, a way to analyse the usage of metadata in Bitcoin is to count the transactions of each protocol.
To this purpose, we construct a view of the blockchain which exposes the protocol
metadata.

More specifically, we build a collection opReturnOutputs whose
documents represent transaction outputs, and are composed of:
(i) the hash of the transaction containing the output;
(ii) the date in which the transaction has been appended to the blockchain;
(iii) the name of the protocol that produced the transaction;
(iv) the metadata contained in the OP_RETURN script.

Several analyses use exchange rates for quantifying the economic impact
of various phenomena (e.g. cyber-crime attacks, transaction fees, business
activities).

In this use case we analyse how the value transferred in transactions
is affected by the exchange rate between USD and BTC over the years. Since
exchange rates are not stored in the Bitcoin blockchain, we need to obtain these
data from an external source, e.g. the Coindesk APIs. Using these data, we
construct a blockchain view where each transaction is associated with the exchange
rate at the time it has been appended to the blockchain.

More specifically, we construct a MongoDB collection whose documents represent
transactions containing:
(i) the transaction hash;
(ii) the sum of its output values (in BTC);
(iii) the date in which the transaction has been appended to the blockchain;
(iv) the exchange rate between BTC and USD in such date.

In this use case we study transaction fees, which are earned by miners when they
append a new block to the Bitcoin blockchain.

Each transaction in the block pays a fee, defined as the difference between its input and output values.
While the values of outputs are stored explicitly in the transaction, those of inputs are not:
to obtain them, one must retrieve from a past block the transaction that is redeemed by the input.
This can be obtained through a “deep” scan of the blockchain, which is featured by our library.

We show how to construct a collection which contains, for each transaction:
(i) the hash of the enclosing block;
(ii) the transaction hash;
(iii) the fee;
(iv) the date in which the transaction was appended to the blockchain;
(v) the exchange rate between BTC and USD in such date.

The website blockchain.info/tags hosts a user-generated list of associations
between bitcoin addresses and tags which briefly describe their usage.
In this section we construct a blockchain view where outputs are associated with
the tags of the address which can redeem them (we discard the outputs with untagged addresses).

More specifically, we construct a collection whose documents represent transaction outputs containing:
(i) hash of the enclosing transaction;
(ii) the date in which the transaction has been appended to the blockchain;
(iii) the output value (in BTC);
(iv) the address receiving the payment;
(v) the tag associated to the address.