Examples

Initialization

1import java.util.HashMap;
2import java.io.IOException;
3import org.arkecosystem.client.Connection;
4import org.arkecosystem.client.api;
5 
6public class Main {
7 public static void main(String[] args) throws IOException {
8 HashMap<String, Object> map = new HashMap<>();
9 map.put("host", "http://my.node.ip:port/api/");
10 map.put("API-Version", 2);
11 Connection connection = new Connection(map);
12 }
13}

Blockchain

Used to get the latest block and supply of the blockchain.

Get blockchain data

1LinkedTreeMap<String, Object> blockchain = connection2.api().blockchain.all();
2 
3>>> LinkedTreeMap<String, Object>

Blocks

This service API grants access to the blocks resource . A block is a signed set of transactions created by a delegate and permanently committed to the ARK blockchain.

It is not possible to POST a block through the public API. Relay Nodes accept only blocks posted by a delegate at the correct time through the internal API.

List All Blocks

1LinkedTreeMap<String, Object> blocks = connection.api().blocks.all();
2 
3>>> LinkedTreeMap<String, Object>

Retrieve a Block

1LinkedTreeMap<String, Object> block = connection.api().blocks.show("validBlockId");
2 
3>>> LinkedTreeMap<String, Object>

Retrieve first block

1LinkedTreeMap<String, Object> block = connection2.api().blocks.first();
2 
3>>> LinkedTreeMap<String, Object>

Retrieve last block

1LinkedTreeMap<String, Object> block = connection2.api().blocks.last();
2 
3>>> LinkedTreeMap<String, Object>

List All Transactions of a Block

1LinkedTreeMap<String, Object> blockTransactions = connection.api().blocks.transactions("validBlockId");
2 
3>>> LinkedTreeMap<String, Object>

Search All Blocks

1LinkedTreeMap<String, Object> searchedBlocks = connection.api().blocks.search(new HashMap<>());
2 
3>>> LinkedTreeMap<String, Object>

Bridgechains

This service API grants access to the bridgechain resource. This can be used to access all registered bridgechains on the network.

List all bridgechains

1LinkedTreeMap<String, Object> bridgechains = connection2.api().bridgechains.all();
2 
3>>> LinkedTreeMap<String, Object>

Retrieve a bridgechain

1LinkedTreeMap<String, Object> bridgechain = connection2.api().bridgechains.show("bridgechains genesis hash");
2 
3>>> LinkedTreeMap<String, Object>

Search bridgechains

1LinkedTreeMap<String, Object> bridgechains = connection2.api().bridgechains.search(new HashMap<>());
2 
3>>> LinkedTreeMap<String, Object>

Businesses

This service API grants access to the business resource. This can be used to access all registered businesses on the network.

List all businesses

1LinkedTreeMap<String, Object> businesses = connection2.api().businesses.all();
2 
3>>> LinkedTreeMap<String, Object>

Retrieve a businesses

1LinkedTreeMap<String, Object> businesses = connection2.api().businesses.show("wallet address");
2 
3>>> LinkedTreeMap<String, Object>

Retrieve all bridgechains of a business

1LinkedTreeMap<String, Object> bridgechains = connection2.api().businesses.showBridgechains("D991ZqskaGWMDu9kpfpJr5LRssV7ek981k");
2 
3>>> LinkedTreeMap<String, Object>

Search businesses

1LinkedTreeMap<String, Object> businesses = connection2.api().businesses.search(new HashMap<>());
2 
3>>> LinkedTreeMap<String, Object>

Delegates

The client SDK can be used to query the delegate resource .

A delegate is a regular wallet that has broadcast a registration transaction, acquired a sufficient number of votes, and has a Relay Node configured to forge new blocks through a forger module. At any time only 51 delegates are active. They are cost-efficient miners running the ARK network.

Voters are wallets which have broadcast a vote transaction on a delegate. A vote remains active until an un-vote transaction is sent (it does not have to be recast unless a wallet wishes to change from delegate). Voting for a delegate does not give the delegate access to the wallet nor does it lock the coins in it.

List All Delegates

1LinkedTreeMap<String, Object> delegates = connection.api().delegates.all();
2 
3>>> LinkedTreeMap<String, Object>

Retrieve a Delegate

1LinkedTreeMap<String, Object> delegate = connection.api().delegates.show("validDelegateId");
2 
3>>> LinkedTreeMap<String, Object>

List All Blocks of a Delegate

1LinkedTreeMap<String, Object> delegateBlocks = connection.api().delegates.blocks("validDelegateId");
2 
3>>> LinkedTreeMap<String, Object>

List All Voters of a Delegate

1LinkedTreeMap<String, Object> delegateVoters = connection.api().delegates.voters("validDelegateId");
2 
3>>> LinkedTreeMap<String, Object>

Search delegates

1LinkedTreeMap<String, Object> delegates = connection2.api().delegates.search(new HashMap<>());
2 
3>>> LinkedTreeMap<String, Object>

Locks

This service API grants access to the lock resource. This can be used to access all locks initiated for wallets.

List all locks

1LinkedTreeMap<String, Object> locks = connection2.api().locks.all();
2 
3>>> LinkedTreeMap<String, Object>

Retrieve a lock

1LinkedTreeMap<String, Object> lock = connection2.api().locks.show("lock id");
2 
3>>> LinkedTreeMap<String, Object>

Search unlocked locks

1LinkedTreeMap<String, Object> unlockedLocks = connection2.api().locks.searchUnlocked(new HashMap<>());
2 
3>>> LinkedTreeMap<String, Object>

Search locks

1LinkedTreeMap<String, Object> locks = connection2.api().locks.search(new HashMap<>());
2 
3>>> LinkedTreeMap<String, Object>

Node

The ARK network consists of different anonymous nodes (servers), maintaining the public ledger, validating transactions and blocks and providing APIs. The node resource allows for querying the health and configurations of the node used by the instantiated client.

Retrieve the Configuration

1LinkedTreeMap<String, Object> nodeConfiguration = connection.api().node.configuration();
2 
3>>> LinkedTreeMap<String, Object>

Retrieve the Status

1LinkedTreeMap<String, Object> nodeStatus = connection.api().node.status();
2 
3>>> LinkedTreeMap<String, Object>

Retrieve the Syncing Status

1LinkedTreeMap<String, Object> nodeSyncingStatus = connection.api().node.syncing();
2 
3>>> LinkedTreeMap<String, Object>

Retrieve the Fees

1LinkedTreeMap<String, Object> fees = connection2.api().node.fees(days);
2 
3>>> LinkedTreeMap<String, Object>

Debug

1LinkedTreeMap<String, Object> debug = connection2.api().node.debug();
2 
3>>> LinkedTreeMap<String, Object>

Peers

Each node is connected to a set of peers, which are Relay or Delegate Nodes as well. The peers resource provides access to all peers connected to our node.

Peers have made their Public API available for use; however for mission-critical queries and transaction posting you should use a node which is under your control. We provide a guide to setting up a Relay Node here .

List All Peers

1LinkedTreeMap<String, Object> peers = connection.api().peers.all();
2 
3>>> LinkedTreeMap<String, Object>

Retrieve a Peer

1LinkedTreeMap<String, Object> peer = connection.api().peers.show("validIpAddress");
2 
3>>> LinkedTreeMap<String, Object>

Rounds

This service API grants access to the round resource. This can be used to access all round information for the network.

List Delegates for a Round

1LinkedTreeMap<String, Object> delegates = connection2.api().rounds.delegates(numberOfARound);
2 
3>>> LinkedTreeMap<String, Object>

Transactions

The heart of any blockchain is formed by its transactions; state-altering payloads signed by a wallet. Most likely you will be querying for transactions most often, using the transaction resource .

A transaction is the only object which may be posted by a non-delegate. It requires a signature from a wallet containing a sufficient amount of ARK.

Create a Transaction

1LinkedTreeMap<String, Object> transaction = connection.api().transactions.create(new ArrayList<>());
2 
3>>> LinkedTreeMap<String, Object>

Retrieve a Transaction

1LinkedTreeMap<String, Object> transaction = connection.api().transactions.show("validTxId");
2 
3>>> LinkedTreeMap<String, Object>

List All Transactions

1LinkedTreeMap<String, Object> transactions = connection.api().transactions.all();
2 
3>>> LinkedTreeMap<String, Object>

List All Unconfirmed Transactions

1LinkedTreeMap<String, Object> unconfirmedTransactions = connection.api().transactions.allUnconfirmed();
2 
3echo gettype($unconfirmedTransactions);
4 
5>>> LinkedTreeMap<String, Object>

Get Unconfirmed Transaction

1LinkedTreeMap<String, Object> unconfirmedTransaction = connection.api().transactions.showUnconfirmed("validTxId");
2 
3echo gettype($unconfirmedTransaction);
4 
5>>> LinkedTreeMap<String, Object>

Search Transactions

1LinkedTreeMap<String, Object> searchedTransactions = connection.api().transactions.search(new HashMap<>());
2 
3>>> LinkedTreeMap<String, Object>

List Transaction Types

1LinkedTreeMap<String, Object> transactionTypes = connection.api().transactions.types();
2 
3>>> LinkedTreeMap<String, Object>

List transaction schemas

1LinkedTreeMap<String, Object> schemas = connection2.api().transactions.schemas();
2 
3>>> LinkedTreeMap<String, Object>

List transaction fees

1LinkedTreeMap<String, Object> fees = connection2.api().transactions.fees();
2 
3>>> LinkedTreeMap<String, Object>

Votes

A vote is a transaction sub-type, where the asset field contains a votes object and the transaction.type is 3.

List All Votes

1LinkedTreeMap<String, Object> votes = connection.api().votes.all();
2 
3>>> LinkedTreeMap<String, Object>

Retrieve a Vote

1LinkedTreeMap<String, Object> actual = connection.api().votes.show("validVoteId");
2 
3>>> LinkedTreeMap<String, Object>

Wallets

The wallet resource provides access to:

  • Wallets.
  • Incoming and outgoing transactions per wallet.
  • Each wallet’s votes.

Retrieve All Wallets

1LinkedTreeMap<String, Object> wallets = connection.api().wallets.all();
2 
3>>> LinkedTreeMap<String, Object>

Retrieve a Wallet

1LinkedTreeMap<String, Object> wallet = connection.api().wallets.show("validWalletId");
2 
3>>> LinkedTreeMap<String, Object>

List All Transactions of a Wallet

1LinkedTreeMap<String, Object> walletTransactions = connection.api().wallets.transactions("validWalletId");
2 
3>>> LinkedTreeMap<String, Object>

List All Received Transactions of a Wallet

1LinkedTreeMap<String, Object> receivedTransactions = connection.api().wallets.receivedTransactions("validWalletId");
2 
3>>> LinkedTreeMap<String, Object>

List All Sent Transactions of a Wallet

1LinkedTreeMap<String, Object> senTransactions = connection.api().wallets.sentTransactions("validWalletId");
2 
3>>> LinkedTreeMap<String, Object>

List All Votes of a Wallet

1LinkedTreeMap<String, Object> walletVotes = connection.api().wallets.votes("validWalletId");
2 
3>>> LinkedTreeMap<String, Object>

List All Top Wallets

1LinkedTreeMap<String, Object> topWallets = connection.api().wallets.top();
2 
3>>> LinkedTreeMap<String, Object>

List locks of a Wallet

1LinkedTreeMap<String, Object> fees = connection2.api().wallets.locks(walletAddress);
2 
3>>> LinkedTreeMap<String, Object>

Search All Wallets

1LinkedTreeMap<String, Object> searchedWallets = connection.api().wallets.search(new HashMap<>());
2 
3>>> LinkedTreeMap<String, Object>
Last updated 3 years ago
Edit Page
Share: