Examples

Initialization

1use ArkEcosystem\Client\Connection;
2 
3$connection = new Connection([
4 'host' => 'http://my.ark.node:port/api/',
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

1$blocks = $connection->blocks()->all();
2 
3echo gettype($blocks);
4 
5>>> array

Retrieve a Block

1$block = $connection->blocks()->show('validBlockId');
2 
3echo gettype($block);
4 
5>>> array

List All Transactions of a Block

1$blockTransactions = $connection->blocks()->transactions('validBlockId');
2 
3echo gettype($blockTransactions);
4 
5>>> array

Search All Blocks

1$searchedBlock = $connection->blocks()->search(['address' => 'validAddress']);
2 
3echo gettype($searchedBlock);
4 
5>>> array

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

1$delegates = $connection->delegates()->all();
2 
3echo gettype($delegates);
4 
5>>> array

Retrieve a Delegate

1$delegate = $connection->delegates()->show('validDelegateId');
2 
3echo gettype($delegate);
4 
5>>> array

List All Blocks of a Delegate

1$delegateBlocks = $connection->delegates()->blocks('validDelegateId');
2 
3echo gettype($delegateBlocks);
4 
5>>> array

List All Voters of a Delegate

1$delegates = $connection->delegates()->voters('validDelegateId');
2 
3echo gettype($delegates);
4 
5>>> array

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

1$nodeConfiguration = $connection->node()->configuration();
2 
3echo gettype($nodeConfiguration);
4 
5>>> array

Retrieve the Status

1$nodeStatus = $connection->node()->status();
2 
3echo gettype($nodeStatus);
4 
5>>> array

Retrieve the Syncing Status

1$nodeSyncingStatus = $connection->node()->syncing();
2 
3echo gettype($nodeSyncingStatus);
4 
5>>> array

Retrieve the Fees

1$nodeFees = $connection->node()->fees();
2 
3echo gettype($nodeFees);
4 
5>>> array

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

1$peers = $connection->peers()->all();
2 
3echo gettype($peers);
4 
5>>> array

Retrieve a Peer

1$peer = $connection->peers()->show('validIpAddress');
2 
3echo gettype($peer);
4 
5>>> array

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

1$transactions = $connection->transactions()->create(['transactions' => []]);
2 
3echo gettype($transactions);
4 
5>>> array

Retrieve a Transaction

1$transaction = $connection->transactions()->show('validTransactionId');
2 
3echo gettype($transaction);
4 
5>>> array

List All Transactions

1$transactions = $connection->transactions()->all();
2 
3echo gettype($transactions);
4 
5>>> array

List All Unconfirmed Transactions

1$unconfirmedTransactions = $connection->transactions()->allUnconfirmed();
2 
3echo gettype($unconfirmedTransactions);
4 
5>>> array

Get Unconfirmed Transaction

1$unconfirmedTransaction = $connection->transactions()->showUnconfirmed('validUnconfirmedTransactionsId');
2 
3echo gettype($unconfirmedTransaction);
4 
5>>> array

Search Transactions

1$transactions = $connection->transactions()->search(['amount' => 1]);
2 
3echo gettype($transactions);
4 
5>>> array

List Transaction Types

1$transactionsTypes = $connection->transactions()->types();
2 
3echo gettype($transactionsTypes);
4 
5>>> array

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

1$votes = $connection->votes()->all();
2 
3echo gettype($votes);
4 
5>>> array

Retrieve a Vote

1$vote = $connection->votes()->show('validTransactionId');
2 
3echo gettype($vote);
4 
5>>> array

Wallets

The wallet resource provides access to:

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

Retrieve All Wallets

1$wallets = $connection->wallets()->all();
2 
3echo gettype($wallets);
4 
5>>> array

Retrieve a Wallet

1$wallet = $connection->wallets()->show('validWalletId');
2 
3echo gettype($wallet);
4 
5>>> array

List All Transactions of a Wallet

1$walletTransactions = $connection->wallets()->transactions('validWalletId');
2 
3echo gettype($walletTransactions);
4 
5>>> array

List All Received Transactions of a Wallet

1$walletReceivedTransactions = $connection->wallets()->receivedTransactions('validWalletId');
2 
3echo gettype($walletReceivedTransactions);
4 
5>>> array

List All Sent Transactions of a Wallet

1$walletSentTransactions = $connection->wallets()->sentTransactions();
2 
3echo gettype($walletSentTransactions);
4 
5>>> array

List All Votes of a Wallet

1$walletVotes = $connection->wallets()->votes('validWalletId');
2 
3echo gettype($walletVotes);
4 
5>>> array

List All Top Wallets

1$topWallets = $connection->wallets()->top();
2 
3echo gettype($topWallets);
4 
5>>> array

Search All Wallets

1$wallet = $connection->wallets()->search(['address' => 'validAddress']);
2 
3echo gettype($wallet);
4 
5>>> array
Last updated 7 months ago
Edit Page
Share:
2022 © ARK.io | All Rights Reserved
An ARK.io Product