id | title |
---|---|
examples |
Examples |
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();
}
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.
let blocks = connection.blocks.all();
>>> Result<Vec<Block>>
let block = connection.blocks.show("validBlockId");
>>> Result<Block>
let blockTransactions = connection.blocks.transactions("validBlockId");
>>> Result<Vec<Transaction>>
let searchedBlock = connection.blocks.search(vec![("id", "validBlockId")]);
>>> Result<Vec<Block>>
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.
let delegates = connection.delegates.all()
>>> Result<Vec<Delegate>>
let delegate = connection.delegates.show("validDelegateId")
>>> Result<Delegate>
let delegateBlocks = connection.delegates.blocks("validDelegateId")
>>> Result<Vec<Block>>
let delegateVoters = connection.delegates.voters("validDelegateId")
>>> Result<Vec<Wallet>>
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.
let nodeConfiguration = connection.node.configuration()
>>> Result<NodeConfiguration>
let nodeStatus = connection.node.status()
>>> Result<NodeStatus>
let nodeSyncingStatus = connection.node.syncing()
>>> Result<NodeSyncing>
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.
let peers = connection.peers.all()
>>> Result<Vec<Peer>>
let peer = connection.peers.show("validIpAddress")
>>> Result<Peer>
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.
let transaction = connection.transactions.create(vec![("id", "dummyId")])
>>> Result<Transaction>
let transaction = connection.transactions.show("validTransactionId")
>>> Result<Transaction>
let transactions = connection.transactions.all()
>>> Result<Vec<Transaction>>
let unconfirmedTransactions = connection.transactions.all_unconfirmed()
>>> Result<Vec<Transaction>>
let unconfirmedTransaction = connection.transactions.show_unconfirmed("validTransactionId")
>>> Result<Vec<Transaction>>
let transactions = connection.transactions.search(vec![("id", "dummyId")])
>>> Result<Vec<Transaction>>
let transactionTypes = connection.transactions.types()
>>> Result<TransactionTypes>
A vote is a transaction sub-type, where the asset
field contains a votes
object and the transaction.type
is 3
.
let votes = connection.votes.all()
>>> Result<Vec<Transaction>>
let vote = connection.votes.show("validVoteId")
>>> Result<Transaction>
The wallet resource provides access to:
- Wallets.
- Incoming and outgoing transactions per wallet.
- Each wallet's votes.
let wallets = connection.wallets.all()
>>> Result<Vec<Wallet>>
let wallet = connection.wallets.show("validWalletId")
>>> Result<Wallet>
let walletTransactions = connection.wallets.transactions("validWalletId")
>>> Result<Vec<Transactions>>
let walletReceivedTransactions = connection.wallets.received_transactions("validWalletId")
>>> Result<Vec<Transactions>>
let walletSentTransactions = connection.wallets.sent_transactions("validWalletId")
>>> Result<Vec<Transactions>>
let walletVotes = connection.wallets.votes("validWalletId")
>>> Result<Vec<Transactions>>
let topWallets = connection.wallets.top()
>>> Result<Vec<Wallets>>
let wallets = connection.wallets.search(vec![("amount", 10000)])
>>> Result<Vec<Wallets>>