ledger - XRPL

Example code for the ledger JSON RPC method. Complete guide to using ledger JSON-RPC in the GetBlock Web3 documentation.

The method retrieves information about the public ledger.

Parameters

Parameter
Type
Required
Description

ledger_hash

string

No

Ledger hash

ledger_index

string/number

No

Ledger index or shortcut

full

boolean

No

Include full ledger

accounts

boolean

No

Include accounts

transactions

boolean

No

Include transactions

expand

boolean

No

Expand transaction details

owner_funds

boolean

No

Include owner_funds

binary

boolean

No

Return binary format

queue

boolean

No

Include queued transactions

Request Example

curl --location --request POST 'https://xrp.getblock.io/mainnet/' \
--header 'x-api-key: YOUR-API-KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "ledger",
    "params": [{
        "ledger_index": "validated",
        "transactions": true
    }],
    "id": "getblock.io"
}'

Response Example

Response Parameters

Parameter
Type
Description

ledger_hash

string

Ledger identifier

ledger_index

number

Ledger sequence

close_time

number

Close time

total_coins

string

Total XRP

Use Cases

  • Get ledger information

  • Retrieve transactions in ledger

  • Monitor ledger state

Error Handling

Error Code
Description

lgrNotFound

Ledger not found

invalidParams

Invalid parameters

SDK Integration

Last updated

Was this helpful?