Examples¶
Initialization¶
const { Connection } = require("@solar-network/client");
const client = new Connection(`${server}/api`);
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 SXP 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¶
Retrieve a Block¶
List All Transactions of a Block¶
Search All Blocks¶
Bridgechains¶
This service API grants access to the bridgechain resource. This can be used to access all registered bridgechains on the network.
List All Bridgechains¶
Retrieve a Bridgechain¶
Search All Bridgechains¶
const response = client.api("bridgechains").search({"bridgechainId": "validId"});
>>> Promise<IResponse<T>>
Businesses¶
This service API grants access to the business resource. This can be used to access all registered businesses on the network.
List All Businesses¶
Retrieve a Business¶
Retrieve all Business Bridgechains¶
Search All Businesses¶
const response = client.api("businesses").search({"businessId": "validId"});
>>> Promise<IResponse<T>>
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 SXP 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¶
Retrieve a Delegate¶
List All Blocks of a Delegate¶
List All Voters of a Delegate¶
Locks¶
This service API grants access to the lock resource. This can be used to access all locks initiated for wallets.
List All Locks¶
Retrieve a Lock¶
Search Locks¶
Get Unlocked Locks¶
Node¶
The SXP 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¶
Retrieve the Status¶
Retrieve the Syncing Status¶
Retrieve the Fees¶
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.
List All Peers¶
Retrieve a Peer¶
Rounds¶
This service API grants access to the round resource. This can be used to access all round information for the network.
List Delegates for a Round¶
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 SXP.
Create a Transaction¶
Retrieve a Transaction¶
List All Transactions¶
List All Unconfirmed Transactions¶
Get Unconfirmed Transaction¶
Search Transactions¶
List Transaction Types¶
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¶
Retrieve a Vote¶
Wallets¶
The wallet resource provides access to:
- Wallets.
- Incoming and outgoing transactions per wallet.
- Each wallet's votes.