Last updated
Edit

ledger

[Source]

Retrieve information about the public ledger.

Request Format

An example of the request format:

{
    "id": "example_ledger_req",
    "command": "ledger",
    "ledger_index": "validated",
    "transactions": false,
    "expand": false,
    "owner_funds": false
}

Try it! >

The request can contain the following parameters:

FieldTypeRequired?Description
ledger_hashHashNoA 32-byte hex string for the ledger version to use. (See Specifying Ledgers).
ledger_indexLedger IndexNoThe ledger index of the ledger to use, or a shortcut string to choose a ledger automatically. (See Specifying Ledgers)
transactionsBooleanNoIf true, return information on transactions in the specified ledger version. The default is false. Ignored if you did not specify a ledger version.
expandBooleanNoProvide full JSON-formatted information for transaction/account information instead of only hashes. The default is false. Ignored unless you request transactions, accounts, or both.
owner_fundsBooleanNoIf true, include owner_funds field in the metadata of OfferCreate transactions in the response. The default is false. Ignored unless transactions are included and expand is true.
binaryBooleanNoIf true, and transactions and expand are both also true, return transaction information in binary format (hexadecimal string) instead of JSON format.
queueBooleanNoIf true, and the command is requesting the current ledger, includes an array of queued transactions in the results.

The ledger field is deprecated and may be removed without further notice. The full, accounts, and type fields (admin-only) are also deprecated; the Clio server does not implement these parameters.

Response Format

An example of a successful response:

{
    "id": "example_ledger_req",
    "result": {
      "ledger": {
        "account_hash": "B8B2C0C3F9E75E3AEE31D467B2544AB56244E618890BA58679707D6BFC0AF41D",
        "close_flags": 0,
        "close_time": 752188602,
        "close_time_human": "2023-Nov-01 21:16:42.000000000 UTC",
        "close_time_resolution": 10,
        "closed": true,
        "ledger_hash": "1BEECD5D21592EABDEF98D8E4BC038AD10B5700FF7E98011870DF5D6C2A2F39B",
        "ledger_index": "83626901",
        "parent_close_time": 752188601,
        "parent_hash": "6B32CFC42B32C5FB90019AE17F701D96B499A4C8E148A002E18135A434A19D98",
        "total_coins": "99988256314388830",
        "transaction_hash": "21586C664DC47E12AF34F22EBF1DB55D23F8C98972542BAC0C39B1009CAC84D4"
      },
      "ledger_hash": "1BEECD5D21592EABDEF98D8E4BC038AD10B5700FF7E98011870DF5D6C2A2F39B",
      "ledger_index": 83626901,
      "validated": true
    },
    "status": "success",
    "type": "response"
}

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

FieldTypeDescription
ledgerObjectThe complete ledger header data of this ledger, with some additional fields added for convenience.
ledger.account_hashStringHash of all account state information in this ledger, as hexadecimal.
ledger.close_flagsNumberA bit-map of flags relating to the closing of this ledger.
ledger.close_timeNumberThe time this ledger was closed, in seconds since the Ripple Epoch.
ledger.close_time_humanStringThe time this ledger was closed, in human-readable format. Always uses the UTC time zone.
ledger.close_time_resolutionNumberLedger close times are rounded to within this many seconds.
ledger.closedBooleanWhether or not this ledger has been closed.
ledger.ledger_hashStringUnique identifying hash of the entire ledger.
ledger.ledger_indexStringThe Ledger Index of this ledger, as a quoted integer.
ledger.parent_close_timeNumberThe time at which the previous ledger was closed.
ledger.parent_hashStringThe unique identifying hash of the ledger that came immediately before this one, as hexadecimal.
ledger.total_coinsStringTotal number of XRP drops in the network, as a quoted integer. (This decreases as transaction costs destroy XRP.)
ledger.transaction_hashStringHash of the transaction information included in this ledger.
ledger.transactionsArray(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_hashStringThe unique identifying hash of the entire ledger, as hexadecimal.
ledger_indexNumberThe Ledger Index of this ledger.
validatedBoolean(May be omitted) If true, this is a validated ledger version. If omitted or set to false, this ledger's data is not final.
queue_dataArray(Omitted unless requested with the queue parameter) Array of objects describing queued transactions, in the same order as the queue. If the request specified expand as true, members contain full representations of the transactions, in either JSON or binary depending on whether the request specified binary as true.

The ledger.accountState field (omitted unless requested with "full": true or "accounts": true) is deprecated.

The following deprecated fields have been removed: accepted, hash (use ledger_hash instead), seqNum (use ledger_index instead), totalCoins (use total_coins instead). Updated in: rippled 1.12.0

Each member of the queue_data array represents one transaction in the queue. Some fields of this object may be omitted because they have not yet been calculated. The fields of this object are as follows:

FieldValueDescription
accountStringThe Address of the sender for this queued transaction.
txString or ObjectBy default, this is a String containing the identifying hash of the transaction. If transactions are expanded in binary format, this is an object whose only field is tx_blob, containing the binary form of the transaction as a decimal string. If transactions are expanded in JSON format, this is an object containing the transaction object including the transaction's identifying hash in the hash field.
retries_remainingNumberHow many times this transaction can be retried before being dropped.
preflight_resultStringThe tentative result from preliminary transaction checking. This is always tesSUCCESS.
last_resultString(May be omitted) If this transaction was left in the queue after getting a retriable (ter) result, this is the exact ter result code it got.
auth_changeBoolean(May be omitted) Whether this transaction changes this address's ways of authorizing transactions.
feeString(May be omitted) The Transaction Cost of this transaction, in drops of XRP.
fee_levelString(May be omitted) The transaction cost of this transaction, relative to the minimum cost for this type of transaction, in fee levels.
max_spend_dropsString(May be omitted) The maximum amount of XRP, in drops, this transaction could potentially send or destroy.

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:

FieldValueDescription
owner_fundsStringNumeric 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.

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.
  • noPermission - If you specified full or accounts as true, but are not connected to the server as an admin (usually, admin requires connecting on localhost).