getLatestLedger
For finding out the current latest known ledger of this node. This is a subset of the ledger info from Horizon.
Params
(0)Result
(getLatestLedgerResponse)Hash identifier of the latest ledger (as a hex-encoded string) known to Stellar RPC at the time it handled the request.
Stellar Core protocol version associated with the latest ledger.
The sequence number of the latest ledger known to Stellar RPC at the time it handled the request.
The timestamp at which the latest ledger was closed.
The LedgerHeader structure for this ledger (base64-encoded string).
The LedgerCloseMeta union for this ledger (base64-encoded string).
Example
Example request to the getLatestLedger method.
Request
- cURL
- JavaScript
- Python
- JSON
curl -X POST \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 8675309,
"method": "getLatestLedger"
}' \
https://soroban-testnet.stellar.org | jq
let requestBody = {
"jsonrpc": "2.0",
"id": 8675309,
"method": "getLatestLedger"
}
let res = await fetch('https://soroban-testnet.stellar.org', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(requestBody),
})
let json = await res.json()
console.log(json)
import json, requests
res = requests.post(https://soroban-testnet.stellar.org, json={
"jsonrpc": "2.0",
"id": 8675309,
"method": "getLatestLedger"
})
print(json.dumps(res.json(), indent=4))
{
"jsonrpc": "2.0",
"id": 8675309,
"method": "getLatestLedger"
}
Result
{
"jsonrpc": "2.0",
"id": 8675309,
"result": {
"id": "0a00a9cf845f7af7cff09c66f8ae6480e9971e6e2c7fa4afd8d6266ee13c987b",
"protocolVersion": 27,
"sequence": 3730795,
"closeTime": "1784671645",
"headerXdr": "CgCpz4RfevfP8Jxm+K5kgOmXHm4sf6Sv2NYmbuE8mHsAAAAbPDCnSG7CFV5/XNDJYU2mvuu7CWlGNETvjzmCB0C50X5Gm4bj+oLrMFjstd6bh+ahjUzOP//fanfkb6k4aruZ5AAAAABqX+2dAAAAAAAAAAEAAAAAtV0Qsrt9KE7VwDpHpeG1kMkPV4NVRxzEUHu+ggTSPIsAAABAcQoxoLTb8SJEAvsbXAetyT2GQeK8HMiN7z2TO4fX56R5roEd2xX5m2ii+FFlVQVErhT4KyxzN/hrbI+v2+9sCzMpCKVWHZKHWvI6d7MnLM0IZhhLZm9Cn43fPxlU5GgZVltQFYhVosSJDb2y8JpoHXePt07R4yONinsPVmZOHtwAOO1rDeC2s6dkAAAAAAO/vpEtPgAAAAAAAAAAAAX17QAAAGQATEtAAAAAyLgswiH76a8cJSTERunnOprBVOsw45eBswHJBh7QOH2GLf4GYAUflwJZdUz+pzyE1xTDFw9wViEEzJVHfgfPMfVBLqU1/WkTSpJrvCDw5YFOwWdTeyV4aQPW1Rg9Gm2gczzsqyuzzw6m/Ea/p4qmm6HSB3cImxjm7GK6fewJsfUzAAAAAAAAAAA=",
"metadataXdr": "AAAAAgAAAAAKAKnPhF9698/wnGb4rmSA6Zcebix/pK/Y1iZu4TyYewAAABs8MKdIbsIVXn9c0MlhTaa+67sJaUY0RO+POYIHQLnRfkabhuP6guswWOy13puH5qGNTM4//99qd+RvqThqu5nkAAAAAGpf7Z0AAAAAAAAAAQAAAAC1XRCyu30oTtXAOkel4bWQyQ9Xg1VHHMRQe76CBNI8iwAAAEBxCjGgtNvxIkQC+xtcB63JPYZB4rwcyI3vPZM7…(truncated for brevity; the full base64 LedgerCloseMeta is large)"
}
}
Using the Lab
You can check the latest known ledger on both Testnet and Mainnet using the getLatestLedger RPC method directly in the Stellar Laboratory.
👉 View Testnet Latest Ledger on the Lab
