Examples
Initialization
extern crate arkecosystem_client;
use arkecosystem_client::connection::Connection;
use arkecosystem_client::api;
fn main() {
let connection = Connection::new("https://my.ark.node:port/api/");
// Parameters are passed as a Vec of string tuples (key, value).
let params = Vec::<(String, String)>::new();
}
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
let blocks = connection.blocks.all();
>>> Result>
Retrieve a Block
let block = connection.blocks.show("validBlockId");
>>> Result
List All Transactions of a Block
let blockTransactions = connection.blocks.transactions("validBlockId");
>>> Result>
Search All Blocks
let searchedBlock = connection.blocks.search(vec![("id", "validBlockId")]);
>>> Result>
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
let delegates = connection.delegates.all()
>>> Result>
Retrieve a Delegate
let delegate = connection.delegates.show("validDelegateId")
>>> Result
List All Blocks of a Delegate
let delegateBlocks = connection.delegates.blocks("validDelegateId")
>>> Result>
List All Voters of a Delegate
let delegateVoters = connection.delegates.voters("validDelegateId")
>>> Result>
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
let nodeConfiguration = connection.node.configuration()
>>> Result
Retrieve the Status
let nodeStatus = connection.node.status()
>>> Result
Retrieve the Syncing Status
let nodeSyncingStatus = connection.node.syncing()
>>> Result
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
let peers = connection.peers.all()
>>> Result>
Retrieve a Peer
let peer = connection.peers.show("validIpAddress")
>>> Result
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
let transaction = connection.transactions.create(vec![("id", "dummyId")])
>>> Result
Retrieve a Transaction
let transaction = connection.transactions.show("validTransactionId")
>>> Result
List All Transactions
let transactions = connection.transactions.all()
>>> Result>
List All Unconfirmed Transactions
let unconfirmedTransactions = connection.transactions.all_unconfirmed()
>>> Result>
Get Unconfirmed Transaction
let unconfirmedTransaction = connection.transactions.show_unconfirmed("validTransactionId")
>>> Result>
Search Transactions
let transactions = connection.transactions.search(vec![("id", "dummyId")])
>>> Result>
List Transaction Types
let transactionTypes = connection.transactions.types()
>>> Result
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
let votes = connection.votes.all()
>>> Result>
Retrieve a Vote
let vote = connection.votes.show("validVoteId")
>>> Result
Wallets
The wallet resource provides access to:
- Wallets.
- Incoming and outgoing transactions per wallet.
- Each wallet’s votes.
Retrieve All Wallets
let wallets = connection.wallets.all()
>>> Result>
Retrieve a Wallet
let wallet = connection.wallets.show("validWalletId")
>>> Result
List All Transactions of a Wallet
let walletTransactions = connection.wallets.transactions("validWalletId")
>>> Result>
List All Received Transactions of a Wallet
let walletReceivedTransactions = connection.wallets.received_transactions("validWalletId")
>>> Result>
List All Sent Transactions of a Wallet
let walletSentTransactions = connection.wallets.sent_transactions("validWalletId")
>>> Result>
List All Votes of a Wallet
let walletVotes = connection.wallets.votes("validWalletId")
>>> Result>
List All Top Wallets
let topWallets = connection.wallets.top()
>>> Result>
Search All Wallets
let wallets = connection.wallets.search(vec![("amount", 10000)])
>>> Result>