Stellar PHP SDK API Documentation

LedgerResponse extends Response

Represents a closed ledger in the Stellar network

This response contains comprehensive ledger details including sequence number, timestamps, transaction and operation counts, fee pool information, base fees, reserves, protocol version, and the ledger header XDR. Each ledger represents a snapshot of the network state at a specific point in time, containing all successful and failed transactions processed in that ledger.

Key fields:

  • Ledger sequence number and hash
  • Transaction counts (successful and failed)
  • Operation counts and fee pool balances
  • Base fee and reserve requirements
  • Protocol version and network configuration
  • Timestamps for ledger closure

Returned by Horizon endpoints:

  • GET /ledgers/{sequence} - Single ledger details
  • GET /ledgers - List of ledgers
Tags
see
LedgerLinksResponse

For related navigation links

see
https://developers.stellar.org

Stellar developer docs Horizon Ledgers API

since
1.0.0

Table of Contents

Properties

$httpClient  : Client|null
$rateLimitLimit  : int|null
$rateLimitRemaining  : int|null
$rateLimitReset  : int|null

Methods

fromJson()  : LedgerResponse
getBaseFeeInStroops()  : int
Gets the base fee charged per operation in this ledger
getBaseReserveInStroops()  : int
Gets the base reserve required per account
getClosedAt()  : string
Gets the timestamp when this ledger was closed
getFailedTransactionCount()  : int|null
Gets the number of failed transactions in this ledger
getFeePool()  : string
Gets the sum of all transaction fees in the fee pool
getHash()  : string
Gets the hash of this ledger
getHeaderXdr()  : string
Gets the base64-encoded XDR representation of the ledger header
getHttpClient()  : Client|null
Gets the HTTP client used for pagination requests
getId()  : string
Gets the unique identifier for this ledger
getLinks()  : LedgerLinksResponse
Gets the links to related resources for this ledger
getMaxTxSetSize()  : int
Gets the maximum number of transactions this ledger can hold
getOperationCount()  : int
Gets the total number of operations in this ledger
getPagingToken()  : string
Gets the paging token for this ledger in list results
getPreviousHash()  : string|null
Gets the hash of the previous ledger in the blockchain
getProtocolVersion()  : int
Gets the protocol version this ledger was running
getRateLimitLimit()  : int|null
Returns X-RateLimit-Limit header from the response.
getRateLimitRemaining()  : int|null
Returns X-RateLimit-Remaining header from the response.
getRateLimitReset()  : int|null
Returns X-RateLimit-Reset header from the response. Seconds until a new window starts.
getSequence()  : BigInteger
Gets the sequence number of this ledger
getSuccessfulTransactionCount()  : int|null
Gets the number of successful transactions in this ledger
getTotalCoins()  : string
Gets the total number of lumens in existence
getTxSetOperationCount()  : int|null
Gets the total number of operations in the transaction set
setHeaders()  : void
Extracts and sets rate limiting information from HTTP response headers
setHttpClient()  : void
Sets the HTTP client for making follow-up requests
loadFromJson()  : void
Loads response data from a JSON array

Properties

$httpClient

protected Client|null $httpClient = null

$rateLimitLimit

protected int|null $rateLimitLimit = null

$rateLimitRemaining

protected int|null $rateLimitRemaining = null

$rateLimitReset

protected int|null $rateLimitReset = null

Methods

getBaseFeeInStroops()

Gets the base fee charged per operation in this ledger

public getBaseFeeInStroops() : int
Return values
int

The base fee in stroops

getBaseReserveInStroops()

Gets the base reserve required per account

public getBaseReserveInStroops() : int
Return values
int

The base reserve in stroops

getClosedAt()

Gets the timestamp when this ledger was closed

public getClosedAt() : string
Return values
string

The ledger close time in ISO 8601 format

getFailedTransactionCount()

Gets the number of failed transactions in this ledger

public getFailedTransactionCount() : int|null
Return values
int|null

The count of failed transactions

getFeePool()

Gets the sum of all transaction fees in the fee pool

public getFeePool() : string
Return values
string

The fee pool balance in stroops

getHash()

Gets the hash of this ledger

public getHash() : string
Return values
string

The ledger hash

getHeaderXdr()

Gets the base64-encoded XDR representation of the ledger header

public getHeaderXdr() : string
Return values
string

The ledger header XDR

getHttpClient()

Gets the HTTP client used for pagination requests

public getHttpClient() : Client|null
Return values
Client|null

The HTTP client instance, or null if not set

getId()

Gets the unique identifier for this ledger

public getId() : string
Return values
string

The ledger ID

getMaxTxSetSize()

Gets the maximum number of transactions this ledger can hold

public getMaxTxSetSize() : int
Return values
int

The maximum transaction set size

getOperationCount()

Gets the total number of operations in this ledger

public getOperationCount() : int
Return values
int

The operation count

getPagingToken()

Gets the paging token for this ledger in list results

public getPagingToken() : string
Return values
string

The paging token used for cursor-based pagination

getPreviousHash()

Gets the hash of the previous ledger in the blockchain

public getPreviousHash() : string|null
Return values
string|null

The previous ledger hash, or null if this is the genesis ledger

getProtocolVersion()

Gets the protocol version this ledger was running

public getProtocolVersion() : int
Return values
int

The protocol version number

getRateLimitLimit()

Returns X-RateLimit-Limit header from the response.

public getRateLimitLimit() : int|null

This number represents the he maximum number of requests that the current client can make in one hour.

Tags
see
https://developers.stellar.org

Stellar developer docs Rate limiting documentation

Return values
int|null

getRateLimitRemaining()

Returns X-RateLimit-Remaining header from the response.

public getRateLimitRemaining() : int|null

The number of remaining requests for the current window.

Tags
see
https://developers.stellar.org

Stellar developer docs Rate limiting documentation

Return values
int|null

getRateLimitReset()

Returns X-RateLimit-Reset header from the response. Seconds until a new window starts.

public getRateLimitReset() : int|null
Tags
see
https://developers.stellar.org

Stellar developer docs Rate limiting documentation

Return values
int|null

getSequence()

Gets the sequence number of this ledger

public getSequence() : BigInteger
Return values
BigInteger

The ledger sequence number

getSuccessfulTransactionCount()

Gets the number of successful transactions in this ledger

public getSuccessfulTransactionCount() : int|null
Return values
int|null

The count of successful transactions

getTotalCoins()

Gets the total number of lumens in existence

public getTotalCoins() : string
Return values
string

The total coins in the network

getTxSetOperationCount()

Gets the total number of operations in the transaction set

public getTxSetOperationCount() : int|null
Return values
int|null

The transaction set operation count

setHeaders()

Extracts and sets rate limiting information from HTTP response headers

public setHeaders(array<string|int, mixed> $headers) : void

This method processes the X-Ratelimit-* headers from the HTTP response and stores them for client access.

Parameters
$headers : array<string|int, mixed>

Associative array of HTTP headers from the response

setHttpClient()

Sets the HTTP client for making follow-up requests

public setHttpClient([Client|null $httpClient = null ]) : void

Paginated responses contain links to next/previous pages. This HTTP client is used when following those links to fetch additional pages.

Parameters
$httpClient : Client|null = null

The Guzzle HTTP client to use for pagination

loadFromJson()

Loads response data from a JSON array

protected loadFromJson(array<string|int, mixed> $json) : void

This method is used internally to populate response objects from parsed JSON. Subclasses override this to extract their specific data fields.

Parameters
$json : array<string|int, mixed>

Associative array of parsed JSON data


        
On this page

Search results