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