Skip to content

blockchain-unica/blockapi

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

BlockAPI: Blockchain analytics API

BlockAPI is a general-purpose blockchain analytics Scala API, maintained by Livio Pompianu and Stefano Lande of the Blockchain@Unica Lab at the University of Cagliari, under the supervision of Massimo Bartoletti.

The standard workflow of BlockAPI consists of two steps:

  1. construct a view of the blockchain (possibly, including external data) and save it in a database;
  2. analyse the view by using the query language of the database.

BlockAPI currently supports Bitcoin and Ethereum, and the DBMS MongoDB, MySQL, PostgreSQL, and Fuseki.

Documentation

Prerequisites

General prerequisites

BlockAPI requires Java JDK 1.8, and it supports the following blockchain clients and DBMSs:

  1. Blockchain clients:
    • Bitcoin Core (Tested with version v0.19.0.1: extracts data from Bitcoin)
    • Parity (Tested with version v2.6.8: extracts data from Ethereum)
  2. DBMS:
    • MongoDB (Tested with version v4.2: constructs a NoSQL view of the data)
    • MySQL (Tested with version v5.7: constructs a SQL view of the data)
    • PostgreSQL (Tested with version v11: constructs a SQL view of the data)
    • Apache Jena Fuseki (Tested with version v3.14.0: constructs a RDF view of the data)

BlockAPI may be used either as an IDE for executing a Scala SBT projects (e.g. IntelliJ IDEA), or via command line (in this case, you need to install SBT.

Further prerequisites may depend on the specific analyses one wants to implement.

Required libraries

This step is required to sucessfully compile the project. Before building the project, execute the following commands:

Bitcoinj
git clone https://github.com/stefanolande/bitcoinj.git
cd bitcoinj
mvn install -DskipTests
cd core
mvn install -DskipTests

Installation

  1. Execute the blockchain client in order to obtain a local copy of the target blockchain (this process may take several hours)
  2. Enable the client RPC calls.
    • In the Bitcoin Core case
      bitcoind -datadir=path/to/blockchain -server -rpcuser=user -rpcpassword=password -rpcserialversion=0
  3. Run a localhost instance of the DBMS on the default port.
  4. Clone this repository.
  5. From your IntelliJ welcome screen: select "Import Project" and open the build.sbt file from your repository directory.

Execution

You can test BlockAPI through one of the use cases in the repository. To do this, either:

  • open the file from your IDE and select run or
  • via command line: from the root directory of the project, execute bash sbt "runMain it.unica.blockchain.analyses.ClassName"

Once BlockAPI has built the database, you can query it using one of the available queries.

Acknowledgments

The project has been supported by several developers at the Department of Mathematics and Computer Science of the University of Cagliari, Italy.