Getting Started

This document indicates elements to drive Coinstack in detail: initial environments, SDK installation, testing, etc.

1. Install Coinstack SDK

1.1. Java SDK

1.1.1. Install JDK

JDK 1.6 or higher version must be prepared for Coinstack Java SDK. You can download the latest version JDK at Oracle Java SE Downloads.

1.1.2. Install Coinstack Java SDK

Best practice for installing Coinstack Java SDK is the package manager like Maven. Otherwise, you can download the latest version of SDK at Maven Repository, installing manually.

With Maven, add below in pom.xml file.


2. Issue Authentication Key

You have to issue your authentication key from Coinstack Dashboard. On [Issuing Key] of Dashboard, press the button [Issuing New Key] and select [API KEY], then Access Key and Secret Key would be created. You cannot check the issued Secret Key again in Dashboard, You must save the Secret Key when it appears.

3. Create and Close Client

Using the issued API Key, create a Coinstack client. CredentialsProvider manages the API Key, and Coinstack Main Net ( is used as Endpoint.

More details about Coinstack Authentication, see Chapter 4. Authentication.

import io.blocko.coinstack.*
import io.blocko.coinstack.model.*

CoinStackClient client = new CoinStackClient(new CredentialsProvider() {
            public String getAccessKey() {
                return "YOUR_COINSTACK_ACCESS_KEY";

            public String getSecretKey() {
                return "YOUR_COINSTACK_SECRET_KEY";
        }, Endpoint.MAINNET);

You can return resources when to complete CoinstackClient as below.


4. Test

4.1. Check Blockchain Status

For checking the installed SDK whether it works ordinarily, you can check the status of Blockchain using the method, getBlockchainStatus. Also, using getBestHeight, you can check the latest block number, and getBestBlockHash returns the hash value of the latest block. The hash value of a block could be used as ID to check an information of the block.

BlockchainStatus status = client.getBlockchainStatus();
System.out.println("bestHeight: "+status.getBestHeight());
System.out.println("bestBlockHash: "+status.getBestBlockHash());

5. Start Coinstack

5.1. Check Block

For garnering an information of the block, the hash value of the block must be taken. In this chapter, it is assumed that the hash value is gotten from the method, getBestBlockHash, which is introduced in the chapter, 'Search Blockchain Status', before. You can get the block object correlated with the hash value, that is, ID, from calling the method, getBlock. The block hash, previous block hash, and block number could be checked by methods of the block object; getBlockId, getParentId, and getHeight respectively.

String blockId = status.getBestBlockHash();
Block block = client.getBlock(blockId);
System.out.println("blockId: "+block.getBlockId());
System.out.println("parentId: "+block.getParentId());
System.out.println("height: "+block.getHeight());

5.2. Check Transaction

The transaction ID must be indicated for checking a transaction. The method, getTransactioinIds, of the block object that is gained before returns the list of transaction IDs included in the block. The example below shows how to check the transaction information using the arbitrary trasaction ID in the list.

You can get the transaction object correlated with the ID using the method, getId, and input/output values can be checked by getInput/getOutput. Transaction can correlate with multiple inputs/outputs.

String[] txIds = block.getTransactionIds();
String txId = txIds[1];
Transaction tx = client.getTransaction(txId);
System.out.println("txId: "+tx.getId());
System.out.println("ins.len: "+tx.getInputs().length);
System.out.println("outs.len: "+tx.getOutputs().length);

5.3. Check Balance in Bitcoin Address

Coinstack SDK provides the method, getBalance, to check the balance of the address. The balance is showed by Satoshi, 1 Satoshi is equated with 0.00000001 Bitcoin.

long balance = client.getBalance("YOUR_BLOCKCHAIN_ADDRESS");
System.out.println("balance: "+balance);

5.4. Check Previous Transactions of Bitcoin Address

Coinstack SDK provides the way to search previous, whole transactional information of the address. Using the method, getTransactions, with the address, you can find the list of formal, total transaction IDs.

String[] txIds = client.getTransactions("YOUR_BLOCKCHAIN_ADDRESS");
for (String txId : txIds) {
    System.out.println("txIds[]: "+txId);

results matching ""

    No results matching ""