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:
- construct a view of the blockchain (possibly, including external data) and save it in a database;
- 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.
- The architecture of BlockAPI and the experimental evaluation of its performance are dicussed in the paper A general framework for blockchain analytics, presented at SERIAL 2017.
- Some common use cases are documented in the project web page.
- The usage of the APIs is documented in the Scaladoc.
- The installation instructions are detailed below in this document.
BlockAPI requires Java JDK 1.8, and it supports the following blockchain clients and DBMSs:
- 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)
- 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.
This step is required to sucessfully compile the project. Before building the project, execute the following commands:
git clone https://github.com/stefanolande/bitcoinj.git
cd bitcoinj
mvn install -DskipTests
cd core
mvn install -DskipTests
- Execute the blockchain client in order to obtain a local copy of the target blockchain (this process may take several hours)
- Enable the client RPC calls.
- In the Bitcoin Core case
bitcoind -datadir=path/to/blockchain -server -rpcuser=user -rpcpassword=password -rpcserialversion=0
- In the Bitcoin Core case
- Run a localhost instance of the DBMS on the default port.
- Clone this repository.
- From your IntelliJ welcome screen: select "Import Project" and open the build.sbt file from your repository directory.
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.
The project has been supported by several developers at the Department of Mathematics and Computer Science of the University of Cagliari, Italy.