Examples

Initialization

1Ark::Client::Connection<Ark::Client::Api> connection("my.node.ip.address", port);

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

1std::string blocks = connection.api.blocks.all()

Retrieve a Block

1std::string block = connection.api.blocks.get("validBlockId")

List All Transactions of a Block

1std::string blockTransactions = connection.api.blocks.transactions("validBlockId")

Search All Blocks

1const std::map<std::string, std::string> body = {
2 { "id", "validBlockId" },
3 { "previousBlock", "validBlockId" },
4 { "version", "validVersion" }
5};
6 
7std::string walletsSearch = connection.api.blocks.search(body);

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

1std::string delegates = connection.api.delegates.all();

Retrieve a Delegate

1std::string delegate = connection.api.delegates.get("validDelegateId");

List All Blocks of a Delegate

1std::string delegateBlocks = connection.api.delegates.blocks("validDelegateId");

List All Voters of a Delegate

1std::string delegateVoters = connection.api.delegates.voters("validDelegateId");

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

1std::string nodeConfiguration = connection.api.node.configuration();

Retrieve the Status

1std::string nodeStatus = connection.api.node.status();

Retrieve the Syncing Status

1std::string nodeSyncing = connection.api.node.syncing();

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

1std::string peers = connection.api.peers.all();

Retrieve a Peer

1std::string peer = connection.api.peers.get("validIpAddress");

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

1std::string jsonTransaction = "{"
2 "\"transactions\":["
3 ...
4 "]"
5"}";
6 
7std::string transaction = connection.api.transactions.send(jsonTransaction);

Retrieve a Transaction

1std::string transaction = connection.api.transactions.get("validTransactionId");

List All Transactions

1std::string transactions = connection.api.transactions.all();

List All Unconfirmed Transactions

1std::string unconfirmedTransactions = connection.api.transactions.allUnconfirmed();

Get Unconfirmed Transaction

1std::string transactionUnconfirmed = connection.api.transactions.getUnconfirmed("validTransactionId");

Search Transactions

1const std::map<std::string, std::string> body = {
2 { "height", "validHeight" }
3};
4 
5std::string transactions = connection.api.transactions.search(body);

List Transaction Types

1std::string transactionTypes = connection.api.transactions.types();

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

1std::string votes = connection.api.votes.all();

Retrieve a Vote

1std::string vote = connection.api.votes.get("validVoteId");

Wallets

The wallet resource provides access to:

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

Retrieve All Wallets

1std::string wallet = connection.api.wallets.all();

Retrieve a Wallet

1std::string wallet = connection.api.wallets.get("validWalletId");

List All Transactions of a Wallet

1std::string walletTransactions = connection.api.wallets.transactions("validAddress");

List All Received Transactions of a Wallet

1std::string walletTransactionsReceived = connection.api.wallets.transactionsReceived("validWalletAddress")

List All Sent Transactions of a Wallet

1std::string walletTransactionsSent = connection.api.wallets.transactionsSent("validWalletAddress")

List All Votes of a Wallet

1std::string walletVotes = connection.api.wallets.votes("validWalletAddress")

List All Top Wallets

1std::string walletsTop = connection.api.wallets.top();

Search All Wallets

1const std::map<std::string, std::string> body_parameters = {
2 { "username", "validUsername" },
3 { "address", "validAddress" },
4 { "publicKey", "validPublicKey" }
5};
6 
7std::string walletsSearch = connection.api.wallets.search(body_parameters);
Last updated 3 years ago
Edit Page
Share: