Stellar is a distributed and open network that allows for the transfer of and storing funds. Jed McCaleb, the founder of Stellar was the one who created Stellar in the hope of providing people with the ability to transfer their fiat currencies with cryptocurrency easily.
Developers who develop applications on foundation of Stellar network application by using Stellar SDKs that they use in the programming language they prefer. SDKs in turn communicate with Horizon Stellar-network API. Horizon offers a means to verify accounts, join to events and make transactions.
Stellar ecosystem runs an API server dubbed Horizon. It functions in the role of an interfacing to Stellar Core and the applications that are part of the Stellar network. It also offers HTTP API for data on Stellar Core. Stellar network. It collects all the data in it’s Stellar network and serves it in a format that is simple to use.
There are many benefits to Horizon’s operation: Horizon using your infrastructure
- Complete operational control, without any dependence from Stellar Development Foundation. Stellar Development Foundation
- Set up multiple instances for capacity and redundancy
- Limiting the rate of request to ensure access to the network
Prerequisites
Horizon is dependent in the PostgreSQL server to store information processed and ingested by Stellar Core. The PostgreSQL Version 9.5 or higher is required to run Horizon.
The additional RAM required is to host Captive Core’s memory database, which would amount to about 3 GB. The other requirement is contingent on the volume of network’s history that you can access from Horizon. Horizon instance. It could be anything from a few GBs up to 10s of TBs for the entire history of ledgers ingested.
Installation
Primarily, prebuilt binaries from Stellar repositories must be installed prior to installing Horizon. If you’re not keen to install prebuilt releases there’s a different option. It is necessary to build Horizon from source. There are a few developers tools must be installed for this purpose:
- OS that is similar to Unix that uses common fundamental commands like mkdir bash, cp, etc.
- Go1.15 or later
- Git
Configuration
Parameters
Both command-line flags as well as environment variables can be used to configure Horizon’s configuration. The following command will check the list of command-line flags as well as their default values, and the associated environmental variables:
Horizon – Help
The command above will show many flags, however only a handful of them are required. The three most crucial parameters are:
- -db-url: It indicates Horizon database, and the value must be an authentic PostgreSQL link URL.
- -captive-core-config-append-path: It points to a Captive Core configuration stub.
- -stellar-core-binary-path: It is a file system path to a Stellar Core binary. Horizon searches the PATH for stellar-core automatically; however, if the environment is properly configured it will not be a requirement to enter the path manually.
Make the database
Create the Horizon database prior to operating the server. The database needs to store all Horizon data, including historic information about transactions on the Stellar network. A new database with no data was created using the PostgreSQL server exclusively for use by Horizon. Next, you need to install the schema using Horizon db init. In Postgre configuration set random_page_cost=1. It allows the query planers to make more efficient use of indexes, specifically for queries using JOIN. Additionally, this setting dramatically increases the speed of certain queries.
Read More : https://www.leewayhertz.com/run-stellar-api-server/