Skip to content

authenteq-zz/java-bigchaindb-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Gitter java-bigchaindb-driver

Official Java driver for BigchainDB created by Authenteq.

Please note: this repo is deprecated. Official repo is moved to https://github.com/bigchaindb/java-bigchaindb-driver

Compatibility

BigchainDB Server BigchainDB Java Driver
1.0 0.1.x
2.0 0.2.x

Contents

Installation and Usage

The build system now is fully gradle-based, so to build the driver run:

./gradlew install

or use maven

mvn clean install

Set up your configuration

BigchainDbConfigBuilder
	.baseUrl("https://test.ipdb.io")
	.addToken("app_id", "2bbaf3ff")
	.addToken("app_key", "c929b708177dcc8b9d58180082029b8d").setup();

Example: Create a Transaction

//    prepare your keys
net.i2p.crypto.eddsa.KeyPairGenerator edDsaKpg = new net.i2p.crypto.eddsa.KeyPairGenerator();
KeyPair keyPair = edDsaKpg.generateKeyPair();

//    Set up your transaction
Transaction transaction = BigchainDbTransactionBuilder.init()
	.addAsset("firstname", "John")
	.addAsset("lastname", "Smith")
	.addMetaData("what", "My first BigchainDB transaction")
	.addMetaData("this", "My 1st metadata BigchainDB transaction")
	.operation(Operations.CREATE)
	.buildOnly((EdDSAPublicKey) keyPair.getPublic(), (EdDSAPrivateKey) keyPair.getPrivate());

Example: Create and Sign Transaction

//    prepare your keys
net.i2p.crypto.eddsa.KeyPairGenerator edDsaKpg = new net.i2p.crypto.eddsa.KeyPairGenerator();
KeyPair keyPair = edDsaKpg.generateKeyPair();

//    Set up your transaction
Transaction transaction = BigchainDbTransactionBuilder.init()
	.addAsset("firstname", "John")
	.addAsset("lastname", "Smith")
	.addMetaData("what", "My second BigchainDB transaction")
	.addMetaData("this", "My 2nd metadata BigchainDB transaction")
	.operation(Operations.CREATE)
	.buildAndSignOnly((EdDSAPublicKey) keyPair.getPublic(), (EdDSAPrivateKey) keyPair.getPrivate());

Example: Create, Sign and Send a Transaction

//    prepare your keys
net.i2p.crypto.eddsa.KeyPairGenerator edDsaKpg = new net.i2p.crypto.eddsa.KeyPairGenerator();
KeyPair keyPair = edDsaKpg.generateKeyPair();

//    Set up your transaction
Transaction transaction = BigchainDbTransactionBuilder.init()
	.addAsset("firstname", "John")
	.addAsset("lastname", "Smith")
	.addMetaData("what", "My third BigchainDB transaction")
	.addMetaData("this", "My 3rd metadata BigchainDB transaction")
	.buildAndSign((EdDSAPublicKey) keyPair.getPublic(), (EdDSAPrivateKey) keyPair.getPrivate())
	.sendTransaction();

Example: Setup Config with Websocket Listener

public class MyCustomMonitor implements MessageHandler {
	@Override
	public void handleMessage(String message) {
		ValidTransaction validTransaction = JsonUtils.fromJson(message, ValidTransaction.class);
	}
}

// config
BigchainDbConfigBuilder
	.baseUrl("https://test.ipdb.io")
	.addToken("app_id", "2bbaf3ff")
	.addToken("app_key", "c929b708177dcc8b9d58180082029b8d")
	.webSocketMonitor(new MyCustomMonitor())
	.setup();
	

Api Wrappers

Transactions

Send a Transaction

TransactionsApi.sendTransaction(Transaction transaction) throws IOException

Send a Transaction with Callback

TransactionsApi.sendTransaction(Transaction transaction, final GenericCallback callback) 

Get Transaction given a Transaction Id

Transaction TransactionsApi.getTransactionById(String id) throws IOException

Get Transaction given an Asset Id

Transactions TransactionsApi.getTransactionsByAssetId(String assetId, Operations operation)

Outputs

Get Outputs given a public key

Outputs getOutputs(String publicKey) throws IOException

Get Spent Outputs given a public key

Outputs getSpentOutputs(String publicKey) throws IOException

Assets

Get Assets given search key

Assets getAssets(String searchKey) throws IOException

Get Assets given search key and limit

Assets getAssetsWithLimit(String searchKey, String limit) throws IOException

Blocks

Get Blocks given block id

Block getBlock(String blockId) throws IOException

Get Blocks given transaction id and status

List<String> getBlocks(String transactionId, String status) throws IOException

Votes

Get Votes given a block id

Votes getVotes(String blockId) throws IOException 

Statuses

Get Transaction status

Status getTransactionStatus(String transactionId) throws IOException

Get Block status

Status getBlockStatus(String blockId) throws IOException

BigchainDB Documentation

Authors

  • The Authenteq team and others (see CONTRIBUTORS file).

License

    java-bigchaindb-driver - Official Java driver for[BigchainDB
    Copyright (C) 2017  Authenteq

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.