stellar-core binary as a subprocess to stream ledgers from the Stellar network. It can be used to stream a ledger range from the past or to stream new ledgers whenever they are confirmed by the network.
Prerequisites
Using captive Core requires stellar-core binary to be installed first.Installation
-
Install Stellar Core:
- Option 1: Build from source by following the Installation Guide
- Option 2: Install via a package manager by referring to the Package-based Installation Guide
-
Verify installation:
Configuration and Usage
Set the captive core configuration for target Stellar network in TOML format. This configuration requires at a minimum:- The passphrase of the Stellar network you want to connect to.
- The path to history archives, necessary for initialization.
CaptiveCoreToml configuration
CaptiveCoreConfig object
Next, create a CaptiveCoreConfig object. This object combines the CaptiveCoreToml configuration with the path to your stellar-core binary and other necessary parameters.
CaptiveStellarCore
Finally, create a CaptiveStellarCore instance using the NewCaptive function. This function manages the complete lifecycle of the stellar-core process, including communication with your application.
captiveStellarCoreBackend can now be used to retrieve ledger data within a specified range. For detailed usage, refer to the code samples.