Examples

Initialization

client = ARKEcosystem.Client.new(%{
host: "http://my.node.ip:myport/api",
nethash: "validNethash",
version: "1.0.0"
})

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

blocks = ARKEcosystem.Client.API.Blocks.list(client)
IO.inspect blocks
>>> ArkEcosystem.Client.response()

Retrieve a Block

block = ARKEcosystem.Client.API.Blocks.show(client, "validBlockId")
IO.inspect block
>>> ArkEcosystem.Client.response()

List All Transactions of a Block

blockTransactions = ARKEcosystem.Client.API.Blocks.transactions(client, "validBlockId")
IO.inspect blockTransactions
>>> ArkEcosystem.Client.response()

Search All Blocks

searchedBlock = ARKEcosystem.Client.API.Blocks.search(client, %{q: "searchQuery"})
IO.inspect searchedBlock
>>> ArkEcosystem.Client.response()

Delegates

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

A delegate is a regular wallet that has broadcasted 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 broadcasted 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

delegates = ARKEcosystem.Client.API.Delegates.list(client)
IO.inspect delegates
>>> ArkEcosystem.Client.response()

Retrieve a Delegate

delegate = ARKEcosystem.Client.API.Delegates.show(client, "validDelegateId")
IO.inspect delegate
>>> ArkEcosystem.Client.response()

List All Blocks of a Delegate

delegateBlocks = ARKEcosystem.Client.API.Delegates.blocks(client, "validDelegateId")
IO.inspect delegateBlocks
>>> ArkEcosystem.Client.response()

List All Voters of a Delegate

delegateVoters = ARKEcosystem.Client.API.Delegates.voters(client, "validDelegateId")
IO.inspect delegateVoters
>>> ArkEcosystem.Client.response()

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

nodeConfiguration = ARKEcosystem.Client.API.Node.configuration(client)
IO.inspect nodeConfiguration
>>> ArkEcosystem.Client.response()

Retrieve the Status

nodeStatus = ARKEcosystem.Client.API.Node.status(client)
IO.inspect nodeStatus
>>> ArkEcosystem.Client.response()

Retrieve the Syncing Status

nodeSyncingStatus = ARKEcosystem.Client.API.Node.syncing(client)
IO.inspect nodeSyncingStatus
>>> ArkEcosystem.Client.response()

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

peers = ARKEcosystem.Client.API.Peers.list(client)
IO.inspect peers
>>> ArkEcosystem.Client.response()

Retrieve a Peer

peer = ARKEcosystem.Client.API.Peers.show(client, "validIpAddress")
IO.inspect peer
>>> ArkEcosystem.Client.response()

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

transaction = ARKEcosystem.Client.API.Transactions.create(client, %{id: "dummyCreatedId"})
IO.inspect transaction
>>> ArkEcosystem.Client.response()

Retrieve a Transaction

transaction = ARKEcosystem.Client.API.Transactions.show(client, "validTransactionId")
IO.inspect transaction
>>> ArkEcosystem.Client.response()

List All Transactions

transactions = ARKEcosystem.Client.API.Transactions.list(client)
IO.inspect transactions
>>> ArkEcosystem.Client.response()

List All Unconfirmed Transactions

unconfirmedTransactions = ARKEcosystem.Client.API.Transactions.list_unconfirmed(client)
IO.inspect unconfirmedTransactions
>>> ArkEcosystem.Client.response()

Get Unconfirmed Transaction

unconfirmedTransaction = ARKEcosystem.Client.API.Transactions.list_unconfirmed(client, "validTransactionId")
IO.inspect unconfirmedTransaction
>>> ArkEcosystem.Client.response()

Search Transactions

transactions = ARKEcosystem.Client.API.Transactions.search(client, %{q: "searchQuery"})
IO.inspect transactions
>>> ArkEcosystem.Client.response()

List Transaction Types

transactionTypes = ARKEcosystem.Client.API.Transactions.types(client)
IO.inspect transactionTypes
>>> ArkEcosystem.Client.response()

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

votes = ARKEcosystem.Client.API.Votes.list(client)
IO.inspect votes
>>> ArkEcosystem.Client.response()

Retrieve a Vote

vote = ARKEcosystem.Client.API.Transactions.types(client, "validVoteId")
IO.inspect vote
>>> ArkEcosystem.Client.response()

Wallets

The wallet resource provides access to:

  • Wallets.

  • Incoming and outgoing transactions per wallet.

  • Each wallet's votes.

Retrieve All Wallets

wallets = ARKEcosystem.Client.API.Wallets.list(client)
IO.inspect wallets
>>> ArkEcosystem.Client.response()

Retrieve a Wallet

wallet = ARKEcosystem.Client.API.Wallets.show(client, "validWalletId")
IO.inspect wallet
>>> ArkEcosystem.Client.response()

List All Transactions of a Wallet

walletTransactions = ARKEcosystem.Client.API.Wallets.transactions(client, "validWalletId")
IO.inspect walletTransactions
>>> ArkEcosystem.Client.response()

List All Received Transactions of a Wallet

walletReceivedTransactions = ARKEcosystem.Client.API.Wallets.received_transactions(client, "validWalletId")
IO.inspect walletReceivedTransactions
>>> ArkEcosystem.Client.response()

List All Sent Transactions of a Wallet

walletSentTransactions = ARKEcosystem.Client.API.Wallets.sent_transactions(client, "validWalletId")
IO.inspect walletReceivedTransactions
>>> ArkEcosystem.Client.response()

List All Votes of a Wallet

walletVotes = ARKEcosystem.Client.API.Wallets.votes(client, "validWalletId")
IO.inspect walletVotes
>>> ArkEcosystem.Client.response()

List All Top Wallets

topWallets = ARKEcosystem.Client.API.Wallets.top(client)
IO.inspect topWallets
>>> ArkEcosystem.Client.response()

Search All Wallets

wallets = ARKEcosystem.Client.API.Wallets.search(client, %{q: "searchQuery"})
IO.inspect wallets
>>> ArkEcosystem.Client.response()