Skip to content

MrBenzene/blockapi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BlockAPI: Blockchain analytics API

A Scala framework for the development of general-purpose analytics on blockchains, maintained by Livio Pompianu and Stefano Lande of the Blockchain@Unica Lab at the University of Cagliari.

The framework allows to combine data within the blockchain with data from the outside (e.g. exchange rates and tags). The workflow consists in two steps:

  1. construct a view of the blockchain and save it in a database;
  2. analyse the view by using the query language of the database.

The blockchains currently supported are Bitcoin and Ethereum. The DBMS currently supported are MongoDB, MySQL, PostgreSQL, and Fuseki.

The library is dicussed in A general framework for blockchain analytics, in proceeding of the SERIAL workshop 2017.

More material is available in the project page.

The Scaladoc is uploaded on this repository in the doc folder.

Install prerequisites

General prerequisites

At the moment, Java JDK 1.8 is needed to run the API.

Prerequisites depends on the target analyses. Generally speaking the framework needs at least one blockchain client and one DBMS.

  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)
  3. Either
    • use an IDE for executing a Scala SBT project (we used IntelliJ IDEA) or
    • use the command line in place of an IDE (Install SBT)

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/bitbart/bitcoinj.git
cd bitcoinj
git checkout segwit
mvn install -DskipTests
cd core
mvn install -DskipTests

Analysis dependent prerequisites

Bitcoin

This instructions are needed for performing analyses on CrossValidation on Bitcoin.

In order to use some analyses on Bitcoin you must require the respective API key:

  1. Blockchain.info
    • It is sufficient to sign up and then active your APIKey

After doing this, do the following: Copy Blockchain key into bitcoin\CrossValidationBitcoin.apiKey attribute

Ethereum

This instructions are needed for performing analyses on CrossValidation on Ethereum.

In order to use some analyses on Bitcoin you must require the respective API key:

  1. EtherScan
    • It is sufficient to sign up and then go here

After doing these steps, do the following: Copy EtherScan key into utils\Etherscan.apiKey attribute

Install blockchain analytics API

  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.

Running

  1. Execute of one of the available examples. Either
    • open the file from your IDE and select run or
    • use the command line: from the root directory of the project, execute
      sbt "runMain it.unica.blockchain.analyses.ClassName"

Our framework will build the selected database. Then you can query it for performing your analysis. For each available Scala script, we provide some default queries along with the resulting csv files.

Acknowledgments

The authors thank the following developers of the Department of Mathematics and Computer Science of the University of Cagliari for their valuable contributions.

About

A general framework for blockchain analytics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Scala 85.5%
  • Java 14.1%
  • Other 0.4%