> ## Documentation Index
> Fetch the complete documentation index at: https://docs.walley.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Reading Ledger State with the Walley Python SDK

> Query active contracts and other Canton JSON Ledger API state through Walley's authenticated proxy — named reads for the common cases, raw passthrough for the rest.

`w.ledger` reads the Canton ledger through Walley's authenticated proxy — the Python twin of the dApp SDK's [`ledgerApi`](/build/ledger-api). Common reads are named methods so you don't need to know ledger endpoints; a raw passthrough covers everything else. The SDK's bearer token is attached automatically.

## Active contracts

The read you'll reach for most, typically to feed contract ids into your dApp's commands:

```python theme={null}
for c in w.ledger.active_contracts():
    print(c.contract_id, c.template_id, c.payload)
```

Filter by template — both id forms work, the package-id form and the package-name form:

```python theme={null}
w.ledger.active_contracts(
    template_ids=["#splice-amulet:Splice.AmuletRules:TransferPreapproval"])

w.ledger.active_contracts(
    template_ids=["6c5802f8...:Splice.AmuletRules:TransferPreapproval"])
```

Each `ActiveContract` lifts the useful fields out of the ledger's nesting:

```python theme={null}
c.contract_id      # feed into your dApp's exercise commands
c.template_id      # <package-id>:Module:Entity
c.payload          # the contract's create arguments (dict)
c.created_event    # the raw ledger createdEvent, for anything else
```

By default the query runs as the client's party at the current ledger end; override with `party_id=`, `at_offset=`, or `verbose=True`.

## Other named reads

```python theme={null}
w.ledger.ledger_end()    # current ledger offset
w.ledger.version()       # ledger API version string
```

## Raw passthrough

For anything the named methods don't cover, forward requests directly — the path is the JSON Ledger API resource:

```python theme={null}
w.ledger.get("/v2/users")
w.ledger.post("/v2/updates/flats", json={...})
w.ledger.request("GET", "/v2/state/ledger-end")
```

<Note>
  The proxy is for **reads**, all submissions go through `w.transactions`. See [Transactions & Fees](/python-sdk/transactions).
</Note>
