Examples

Client Setup

The first step is always to create a Client through which you'll interact with the ARK Blockchain. By default you can use the Public API provided by the ARK network, but you can also add your own node instead.

With the public API, our setup has separate domains for each of the API endpoints and should be configured as follows:

TODO

In case of using your own node, with Mainsail's default configuration and accessing it locally, you will want to use this instead:

TODO

In either case, mind the /api suffix for the endpoints. For the other examples, the $client we created will be used.

Retrieving a Nonce

A nonce is a number that is used only once. It is a unique identifier issued in a transaction to ensure that the transaction is not duplicated. The nonce is used to prevent replay attacks.

TODO

This nonce can then be used while constructing a transaction. Mind that you can also locally increment the nonce if you are sending multiple transactions in a row, as the next nonce is always the last used nonce + 1;

Broadcasting a Transactions

After signing a transaction, you can broadcast it to the network using the public API SDK. The SDK will handle the serialization and deserialization of the transaction object. This is a combined effort from the Crypto and Client SDKs. For this we assume you already have a signed transaction builder object stored in a variable named $builder, e.g. from the crypto SDK examples, and a $client object initialized to interact with the network.

TODO

The result will indicate to you if the transaction was successfully broadcasted to the network and accepted or if any issues occured. Note that being accepted on the network only indicates if the transaction is constructed well and the signature is correct. It does not guarantee that the transaction will be able to be processed in the EVM, so you will want to keep an eye on the next block to see if your transaction was successfully executed.

API Retrieval Examples

For general API retrieval examples, we'd like to refer you to the Public API documentation. There each endpoint is covered with copy and paste examples for each of the languages the SDKs support.