Examples

Initialization

1client = ArkEcosystem.Client.new(%{
2 host: "http://my.node.ip:myport/api",
3 nethash: "validNethash",
4 version: "1.0.0"
5})

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

1blocks = ArkEcosystem.Client.API.Blocks.list(client)
2 
3IO.inspect blocks
4 
5>>> ArkEcosystem.Client.response()

Retrieve a Block

1block = ArkEcosystem.Client.API.Blocks.show(client, "validBlockId")
2 
3IO.inspect block
4 
5>>> ArkEcosystem.Client.response()

List All Transactions of a Block

1blockTransactions = ArkEcosystem.Client.API.Blocks.transactions(client, "validBlockId")
2 
3IO.inspect blockTransactions
4 
5>>> ArkEcosystem.Client.response()

Search All Blocks

1searchedBlock = ArkEcosystem.Client.API.Blocks.search(client, %{q: "searchQuery"})
2 
3IO.inspect searchedBlock
4 
5>>> ArkEcosystem.Client.response()

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

1delegates = ArkEcosystem.Client.API.Delegates.list(client)
2 
3IO.inspect delegates
4 
5>>> ArkEcosystem.Client.response()

Retrieve a Delegate

1delegate = ArkEcosystem.Client.API.Delegates.show(client, "validDelegateId")
2 
3IO.inspect delegate
4 
5>>> ArkEcosystem.Client.response()

List All Blocks of a Delegate

1delegateBlocks = ArkEcosystem.Client.API.Delegates.blocks(client, "validDelegateId")
2 
3IO.inspect delegateBlocks
4 
5>>> ArkEcosystem.Client.response()

List All Voters of a Delegate

1delegateVoters = ArkEcosystem.Client.API.Delegates.voters(client, "validDelegateId")
2 
3IO.inspect delegateVoters
4 
5>>> 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

1nodeConfiguration = ArkEcosystem.Client.API.Node.configuration(client)
2 
3IO.inspect nodeConfiguration
4 
5>>> ArkEcosystem.Client.response()

Retrieve the Status

1nodeStatus = ArkEcosystem.Client.API.Node.status(client)
2 
3IO.inspect nodeStatus
4 
5>>> ArkEcosystem.Client.response()

Retrieve the Syncing Status

1nodeSyncingStatus = ArkEcosystem.Client.API.Node.syncing(client)
2 
3IO.inspect nodeSyncingStatus
4 
5>>> 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

1peers = ArkEcosystem.Client.API.Peers.list(client)
2 
3IO.inspect peers
4 
5>>> ArkEcosystem.Client.response()

Retrieve a Peer

1peer = ArkEcosystem.Client.API.Peers.show(client, "validIpAddress")
2 
3IO.inspect peer
4 
5>>> 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

1transaction = ArkEcosystem.Client.API.Transactions.create(client, %{id: "dummyCreatedId"})
2 
3IO.inspect transaction
4 
5>>> ArkEcosystem.Client.response()

Retrieve a Transaction

1transaction = ArkEcosystem.Client.API.Transactions.show(client, "validTransactionId")
2 
3IO.inspect transaction
4 
5>>> ArkEcosystem.Client.response()

List All Transactions

1transactions = ArkEcosystem.Client.API.Transactions.list(client)
2 
3IO.inspect transactions
4 
5>>> ArkEcosystem.Client.response()

List All Unconfirmed Transactions

1unconfirmedTransactions = ArkEcosystem.Client.API.Transactions.list_unconfirmed(client)
2 
3IO.inspect unconfirmedTransactions
4 
5>>> ArkEcosystem.Client.response()

Get Unconfirmed Transaction

1unconfirmedTransaction = ArkEcosystem.Client.API.Transactions.list_unconfirmed(client, "validTransactionId")
2 
3IO.inspect unconfirmedTransaction
4 
5>>> ArkEcosystem.Client.response()

Search Transactions

1transactions = ArkEcosystem.Client.API.Transactions.search(client, %{q: "searchQuery"})
2 
3IO.inspect transactions
4 
5>>> ArkEcosystem.Client.response()

List Transaction Types

1transactionTypes = ArkEcosystem.Client.API.Transactions.types(client)
2 
3IO.inspect transactionTypes
4 
5>>> 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

1votes = ArkEcosystem.Client.API.Votes.list(client)
2 
3IO.inspect votes
4 
5>>> ArkEcosystem.Client.response()

Retrieve a Vote

1vote = ArkEcosystem.Client.API.Transactions.types(client, "validVoteId")
2 
3IO.inspect vote
4 
5>>> ArkEcosystem.Client.response()

Wallets

The wallet resource provides access to:

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

Retrieve All Wallets

1wallets = ArkEcosystem.Client.API.Wallets.list(client)
2 
3IO.inspect wallets
4 
5>>> ArkEcosystem.Client.response()

Retrieve a Wallet

1wallet = ArkEcosystem.Client.API.Wallets.show(client, "validWalletId")
2 
3IO.inspect wallet
4 
5>>> ArkEcosystem.Client.response()

List All Transactions of a Wallet

1walletTransactions = ArkEcosystem.Client.API.Wallets.transactions(client, "validWalletId")
2 
3IO.inspect walletTransactions
4 
5>>> ArkEcosystem.Client.response()

List All Received Transactions of a Wallet

1walletReceivedTransactions = ArkEcosystem.Client.API.Wallets.received_transactions(client, "validWalletId")
2 
3IO.inspect walletReceivedTransactions
4 
5>>> ArkEcosystem.Client.response()

List All Sent Transactions of a Wallet

1walletSentTransactions = ArkEcosystem.Client.API.Wallets.sent_transactions(client, "validWalletId")
2 
3IO.inspect walletReceivedTransactions
4 
5>>> ArkEcosystem.Client.response()

List All Votes of a Wallet

1walletVotes = ArkEcosystem.Client.API.Wallets.votes(client, "validWalletId")
2 
3IO.inspect walletVotes
4 
5>>> ArkEcosystem.Client.response()

List All Top Wallets

1topWallets = ArkEcosystem.Client.API.Wallets.top(client)
2 
3IO.inspect topWallets
4 
5>>> ArkEcosystem.Client.response()

Search All Wallets

1wallets = ArkEcosystem.Client.API.Wallets.search(client, %{q: "searchQuery"})
2 
3IO.inspect wallets
4 
5>>> ArkEcosystem.Client.response()
Last updated 2 years ago
Edit Page
Share: