-
Notifications
You must be signed in to change notification settings - Fork 233
Kundera with Ethereum Blockchain
Ethereum is a decentralized platform that runs smart contracts: applications that run exactly as programmed without any possibility of downtime, censorship, fraud or third party interference. These apps run on a custom built blockchain, an enormously powerful shared global infrastructure that can move value around and represent the ownership of property.
It is not possible to perform queries over multiple blocks or transactions on ethereum public data using various native clients.
One solution could be to migrate blocks' data to any database and perform queries there. Kundera-Ethereum will help in that migration. It uses Web3j API to fetch blocks' data. It creates Block
and Transaction
objects and persist them in the Kundera supported database of your choice via JPA route.
Ideally, all the databases supported by Kundera can be used to import ethereum blocks. But we have tested -
- MongoDB
- RethinkDB
- Cassandra
- HBase
Feel free to use any database. Let us know if you face any issue with it.
<dependency>
<groupId>com.impetus.kundera.client</groupId>
<artifactId>kundera-ethereum</artifactId>
<version>${kundera.version}</version>
</dependency>
You need to put following properties in this file -
-
database.type
- Mention database type like MongoDB, HBase, etc. -
database.host
- IP address or hostname of the database -
database.port
- Port number of the database -
database.name
- Name of the database in which you want to storeBlock
andTransaction
Table. -
database.username
(optional) - Username of the database -
database.password
(optional) - Password of the database -
schema.auto.generate
(optional) - Set true, if you want Kundera to create database and tables for you. -
schema.drop.existing
(optional) - Set true, if you want Kundera to delete existing database and tables for you.
-
ethereum.node.endpoint
- There are 3 options here- Using RPC HTTP end point. e.g.
http://localhost:8545/
- Using IPC socket file location. e.g.
/home/dev/ethereum/geth.ipc
- Using Infura end point. e.g.
https://mainnet.infura.io/<your-token>
-
ethereum.node.os
(optional) - Setwindows
, only needed if you are using IPC socket file to connect in the above property and its located on windows OS.
- Using RPC HTTP end point. e.g.
Check sample properties file here.
That's it! Start importing data now.
-
To import all the data starting from genesis block:
BlockchainImporter importer = BlockchainImporter.initialize(); importer.importUptoLatestBlock();
-
To import all the data starting from 1000000th block:
BlockchainImporter importer = BlockchainImporter.initialize(); importer.importUptoLatestBlock(BigInteger.valueOf(1000000));
-
To import the data starting from 1000000th to 2000000th block:
BlockchainImporter importer = BlockchainImporter.initialize(); importer.importBlocks(BigInteger.valueOf(1000000), BigInteger.valueOf(2000000));
You can also opt for saving upcoming blocks:
BlockchainImporter importer = BlockchainImporter.initialize();
importer.importUptoLatestAndSyncNewBlocks();
Check testcase for more features.
After importing data, JPA queries can be performed using normal Kundera way. Sample:
Query query = em.createQuery(
"Select t.gas,t.gasPrice from Transaction t where t.blockNumber='0x455a56' and t.from='0x6c15291028d082e1b9358e19f15c83b9c54f2b35'");
List<Transaction> results = query.getResultList();
Check testcase for details.
-
Datastores Supported
- Releases
-
Architecture
-
Concepts
-
Getting Started in 5 minutes
-
Features
- Object Mapper
- Polyglot Persistence
- Queries Support
- JPQL (JPA Query Language)
- Native Queries
- Batch insert update
- Schema Generation
- Primary Key Auto generation
- Transaction Management
- REST Based Access
- Geospatial Persistence and Queries
- Graph Database Support
-
Composite Keys
-
No hard annotation for schema
-
Support for Mapped superclass
-
Object to NoSQL Data Mapping
-
Cassandra's User Defined Types and Indexes on Collections
-
Support for aggregation
- Scalar Queries over Cassandra
- Connection pooling using Kundera Cassandra
- Configuration
-
Kundera with Couchdb
-
Kundera with Elasticsearch
-
Kundera with HBase
-
Kundera with Kudu
-
Kundera with RethinkDB
-
Kundera with MongoDB
-
Kundera with OracleNoSQL
-
Kundera with Redis
-
Kundera with Spark
-
Extend Kundera
- Sample Codes and Examples
-
Blogs and Articles
-
Tutorials
* Kundera with Openshift
* Kundera with Play Framework
* Kundera with GWT
* Kundera with JBoss
* Kundera with Spring
-
Performance
-
Troubleshooting
-
FAQ
- Production deployments
- Feedback