ledger

The ledger command retrieves information about the public ledger.

New in: Clio v1.0.0

Note that the Clio server returns validated ledger data by default.

Request Format

An example of the request format:

curl --location 'https://xrp.nownodes.io' \
--header 'Content-Type: application/json' \
--header 'api-key: API_KEY' \
--data '{
    "method": "ledger",
    "params": [
        {
            "ledger_index": "validated",
            "accounts": false,
            "full": false,
            "transactions": false,
            "expand": false,
            "owner_funds": false,
            "diff": false
        }
    ]
}'

The request can contain the following parameters:

Field

Type

Description

ledger_hash

[Hash][]

(Optional) A 20-byte hex string for the ledger version to use. (See [Specifying Ledgers][]).

ledger_index

[Ledger Index][]

(Optional) The [ledger index][] of the ledger to use, or a shortcut string to choose a ledger automatically. (See [Specifying Ledgers][])

transactions

Boolean

(Optional) If true, return information on transactions in the specified ledger version. Defaults to false. Ignored if you did not specify a ledger version.

expand

Boolean

(Optional) Provide full JSON-formatted information for transaction/account information instead of only hashes. Defaults to false. Ignored unless you request transactions.

owner_funds

Boolean

(Optional) If true, include owner_funds field in the metadata of OfferCreate transactions in the response. Defaults to false. Ignored unless transactions are included and expand is true.

binary

Boolean

(Optional) If true, and transactions and expand are both also true, return transaction information in binary format (hexadecimal string) instead of JSON format.

diff

Boolean

(Optional) If true, returns all objects that were added, modified, or deleted as part of applying transactions in the specified ledger.

The ledger field is deprecated and may be removed without further notice.

The ledger command in Clio does not support the following fields that are supported by ledger command in rippled:

  • accounts

  • full

  • queue

Clio will always forward the request to rippled when any of the above fields is set to true.

Response Format

An example of a successful response:

{
    "result": {
        "ledger": {
            "account_hash": "2783F3575DE97B7D13ADDD94F28FE43DDB2BCB8E0DAFB1F7E9F09DE0AD7C296F",
            "close_flags": 0,
            "close_time": 768686520,
            "close_time_human": "2024-May-10 20:02:00.000000000 UTC",
            "close_time_iso": "2024-05-10T20:02:00Z",
            "close_time_resolution": 10,
            "closed": true,
            "ledger_hash": "00296144F5F759A5A2061357F9267F52CE2E2DC27C377BF92E3ED0038C985785",
            "ledger_index": "87899063",
            "parent_close_time": 768686512,
            "parent_hash": "9938244A5AB107BFA865C3C599568C5E4FD4E0ECDFFC74C8F7F3A924171DED67",
            "total_coins": "99987599116313557",
            "transaction_hash": "1821D261C6DB74DE4210FC7F15870C17E5A322E4DAD4B8D703424D1D096D94DC"
        },
        "ledger_hash": "00296144F5F759A5A2061357F9267F52CE2E2DC27C377BF92E3ED0038C985785",
        "ledger_index": 87899063,
        "status": "success",
        "validated": true
    }
}

The response follows the [standard format][], with a successful result containing information about the ledger, including the following fields:

Field

Type

Description

ledger

Object

The complete header data of this ledger.

ledger.account_hash

String

Hash of all account state information in this ledger, as hex

ledger.accountState

Array

(Omitted unless requested) All the account-state information in this ledger.

ledger.close_flags

Integer

A bit-map of flags relating to the closing of this ledger.

ledger.close_time

Integer

The time this ledger was closed, in [seconds since the Ripple Epoch][].

ledger.close_time_human

String

The time this ledger was closed, in human-readable format. Always uses the UTC time zone.

ledger.close_time_resolution

Integer

Ledger close times are rounded to within this many seconds.

ledger.closed

Boolean

Whether or not this ledger has been closed.

ledger.ledger_hash

String

Unique identifying hash of the entire ledger.

ledger.ledger_index

String

The [Ledger Index][] of this ledger, as a quoted integer.

ledger.parent_close_time

Integer

The time at which the previous ledger was closed.

ledger.parent_hash

String

Unique identifying hash of the ledger that came immediately before this one.

ledger.total_coins

String

Total number of XRP drops in the network, as a quoted integer. (This decreases as transaction costs destroy XRP.)

ledger.transaction_hash

String

Hash of the transaction information included in this ledger, as hex.

ledger.transactions

Array

(Omitted unless requested) Transactions applied in this ledger version. By default, members are the transactions' identifying [Hash][] strings. If the request specified expand as true, members are full representations of the transactions instead, in either JSON or binary depending on whether the request specified binary as true.

ledger_hash

String

Unique identifying hash of the entire ledger.

ledger_index

Number

The [Ledger Index][] of this ledger.

validated

Boolean

(May be omitted) If true, this is a validated ledger version. If omitted or set to false, this ledger's data is not final.

diff

Object

(Omitted unless requested with the diff parameter) Object containing an array of hashes that were added, modified, or deleted as part of applying transactions for the ledger.

If the request specified "owner_funds": true and expanded transactions, the response has a field owner_funds in the metaData object of each [OfferCreate transaction][]. The purpose of this field is to make it easier to track the funding status of offers with each new validated ledger. This field is defined slightly differently than the version of this field in Order Book subscription streams:

Field

Value

Description

owner_funds

String

Numeric amount of the TakerGets currency that the Account sending this OfferCreate transaction has after the execution of all transactions in this ledger. This does not check whether the currency amount is frozen.

If the request specified "diff": true, the response has an object diff. The fields of this object are as follows:

Field

Value

Description

object_id

String

The object identifier.

Hashes

Object or Hex String

Depending on whether the request set binary to true or false, this field returns the contents of the object that was created, the new value of an object that was modified, or an empty string if the object was deleted.

Possible Errors

  • Any of the [universal error types][].

  • invalidParams - One or more fields are specified incorrectly, or one or more required fields are missing.

  • lgrNotFound - The ledger specified by the ledger_hash or ledger_index does not exist, or it does exist but the server does not have it.

Last updated