> For the complete documentation index, see [llms.txt](https://docs.mercurydata.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mercurydata.app/~/changes/KX2wpglbthtd9RsHwz3R/zephyr-full-customization/learn/accessing-the-ledger.md).

# Accessing the Ledger

Learn how you can directly access the Stellar ledger from a zephyr program.

Zephyr's host environment also provides functions to be able to access the ledger maintained by the stellar nodes that live on our server. This grants Zephyr programs first-class access to fast data retrieval and makes up for programs that are omniscient of what's happening in the chain, not only in each ledger close.

{% hint style="warning" %}
There is currently only a limited set of data structures that can be retrieved from the Stellar ledger, we are still developing the others!
{% endhint %}

## Reading contract data entries

You can read contract data entries from the ledger using the following `EnvClient` methods:

```rust
/// Returns the instance object of a certain contract from
/// the host's ledger.
pub fn read_contract_instance(&self, contract: [u8; 32]) -> Result<Option<ContractDataEntry>, SdkError> {}

/// Returns the requested entry object of a certain contract 
/// from the host's ledger.
pub fn read_contract_entry_by_key(&self, contract: [u8; 32], key: ScVal) -> Result<Option<ContractDataEntry>, SdkError> {}

/// Returns all the entry objects of a certain contract 
/// from the host's ledger.
pub fn read_contract_entries(&self, contract: [u8; 32]) -> Result<Vec<ContractDataEntry>, SdkError> {}

/// Returns all the entry objects of a certain contract 
/// from the host's ledger. This function retuns an iteraror
/// over Soroban host objects, and should be used along with the
/// Soroban SDK.
pub fn read_contract_entries_to_env(&self, env: &soroban_sdk::Env, contract: [u8; 32]) -> Result<Map<Val, Val>, SdkError> {}
```

These functions are quite straightforward and are a good tool for zephyr ingestion programs to fetch directly from the ledger's state, but are even more important for [Zephyr Functions](/~/changes/KX2wpglbthtd9RsHwz3R/zephyr-full-customization/zephyr-functions.md) which are not in production yet, but will grant powerful on-request access to the ledger.&#x20;
