> For the complete documentation index, see [llms.txt](https://help.multisig.ledger.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.multisig.ledger.com/guides/cli-guides/querying-safe-data.md).

# Querying Safe data

Read-only commands to inspect Safes and transactions. Nothing on this page consumes a signer or costs gas. You can run these commands without a Ledger and without ever calling `lem connect`, with one exception (`lem safe scan`, which needs the cached signer address to know what to scan for).

This page is the CLI counterpart to [1. Querying Safe Data](https://help.multisig.ledger.com/guides/1.-querying-safe-data) and produces the same JSON shapes as the underlying Safe API Kit.

### What you'll learn

* List Safes owned by the connected signer.
* Fetch Safe configuration, balances, and next nonce.
* List pending and historical transactions for a Safe.
* Fetch a specific transaction by its safeTxHash.

### Prerequisites

* `lem` installed (see **Installation**).
* For `lem safe scan`: a paired signer (see **Configuring a signer**). Every other command on this page only needs a Safe address.

### Step-by-step

#### 1. Scan Safes you own

Lists every Safe (across every supported chain) where the connected signer is an owner.

```
lem safe scan --pretty
```

Output:

```
{
  "address": "0xYourSignerAddress",
  "safes": [
    { "address": "0xSafeOnSepolia", "chainId": 11155111 },
    { "address": "0xSafeOnMainnet", "chainId": 1 }
  ]
}
```

This is the standard way to discover Safes from an agent harness. Feed the output into whichever workflow comes next.

#### 2. Get Safe info

Retrieve owners, threshold, on-chain nonce, version, modules, fallback handler, and guard.

```
lem safe info \
  --address 0xYourSafeAddress \
  --chain-id 11155111 \
  --pretty
```

The shape mirrors the Safe Client Gateway's Safe info response and matches what apiKit.getSafeInfo() returns in the TS guides.

#### 3. Fetch balances

Native ETH + ERC-20 balances held by the Safe.

```
lem safe balances \
  --address 0xYourSafeAddress \
  --chain-id 11155111 \
  --pretty
```

Each entry contains `tokenAddress`, `token` (with symbol and decimals), and a raw integer balance. Format to a human-readable value using the decimals field. See [Guide 1, step 3](https://help.multisig.ledger.com/guides/1.-querying-safe-data) for a worked example.

#### 4. Get the next nonce

Returns the next Safe nonce, accounting for any pending (not-yet-executed) transactions. Use this when you want to queue a new transaction behind everything already proposed.

```
lem safe nonce \
  --address 0xYourSafeAddress \
  --chain-id 11155111
```

Output is a single integer printed to stdout. It is easy to capture into a shell variable:

```
NEXT=$(lem safe nonce --address 0xSafe --chain-id 11155111)
```

#### 5. List transactions

By default `lem tx list` returns only **pending** transactions. This is most useful for "what needs my signature?" workflows. Pass `--all` for the full history.

```
# Pending only
lem tx list \
  --address 0xYourSafeAddress \
  --chain-id 11155111 \
  --pretty

# Including executed & rejected
lem tx list \
  --address 0xYourSafeAddress \
  --chain-id 11155111 \
  --all \
  --pretty
```

`--limit` and `--offset` work for pagination. Each result includes `safeTxHash`, `nonce`, `to`, `value`, `data`, `isExecuted`, `isSuccessful`, and the array of confirmations collected so far.

#### 6. Show a transaction

Fetch the full record for one transaction by its safeTxHash.

```
lem tx show --safe-tx-hash 0xYourSafeTxHash --pretty
```

The output is identical to a Safe API Kit getTransaction response: full transaction data, every collected confirmation (with signer address and signature), and the execution status / on-chain hash once executed.

### Key concepts

> **The Safe Transaction Service is an off-chain index.** It tracks on-chain Safe state (owners, threshold, nonce) and stores proposals before they hit chain. `lem` queries Ledger's hosted instance of this service, so any transaction proposed via the Ledger Multisig UI is visible to the CLI, and vice versa.

### Tips and pitfalls

* **Pipe everything through** `jq`. `lem` prints minified JSON by default, so commands compose cleanly:

  ```
  lem safe info --address 0xSafe --chain-id 1 | jq '.threshold'
  lem tx list --address 0xSafe --chain-id 1 | jq '.results[].safeTxHash'
  ```
* **Indexer lag.** After an execute, expect 10–60 seconds before `lem tx show` flips `isExecuted` to `true`.
* **Pagination.** Large Safes can have many transactions. `lem tx list --all --limit 50 --offset 0` is the right way to page through history.

### Next steps

* **Proposing, signing & executing**
* **Command reference**
