> For the complete documentation index, see [llms.txt](https://docs.seismic.systems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.seismic.systems/clients/typescript/react/hooks/useshieldedread.md). Agents can also search and read this documentation through its [MCP server](https://docs.seismic.systems/~gitbook/mcp).

# useShieldedRead

Execute authenticated read calls on shielded contracts

{% hint style="info" %}
This hook wraps `useSignedReadContract` from seismic-react. The actual export name is `useSignedReadContract`.
{% endhint %}

Hook for performing signed reads -- authenticated `eth_call` requests where the caller proves their identity. This allows contracts to return caller-specific shielded data (for example, a balance that depends on `msg.sender`).

```typescript
import { useSignedReadContract } from "seismic-react";
```

## Config

| Parameter      | Type                                                                                | Required | Description                                                           |
| -------------- | ----------------------------------------------------------------------------------- | -------- | --------------------------------------------------------------------- |
| `address`      | `` `0x${string}` ``                                                                 | Yes      | Contract address                                                      |
| `abi`          | `Abi`                                                                               | Yes      | Contract ABI                                                          |
| `functionName` | `string`                                                                            | Yes      | Name of the view/pure function to call                                |
| `args`         | `array`                                                                             | No       | Arguments to pass to the function                                     |
| `gasPayment`   | [`GasPayment`](https://docs.seismic.systems/clients/typescript/viem/gas-payment.md) | No       | Public signed selector, default Auto; does not charge canonical state |

## Return Type

| Property     | Type                 | Description                         |
| ------------ | -------------------- | ----------------------------------- |
| `signedRead` | `() => Promise<any>` | Function to execute the signed read |
| `read`       | `() => Promise<any>` | Alias for signedRead                |
| `isLoading`  | `boolean`            | Whether a read is in progress       |
| `error`      | `Error \| null`      | Error from the most recent read     |

***

## Usage

### Reading a shielded balance

```typescript
import { useSignedReadContract } from 'seismic-react'
import { useState } from 'react'

const abi = [
  {
    name: 'balanceOf',
    type: 'function',
    stateMutability: 'view',
    inputs: [],
    outputs: [{ name: '', type: 'uint256' }],
  },
] as const

function ShieldedBalance() {
  const [balance, setBalance] = useState<string | null>(null)

  const { signedRead, isLoading, error } = useSignedReadContract({
    address: '0x1234567890abcdef1234567890abcdef12345678',
    abi,
    functionName: 'balanceOf',
  })

  async function fetchBalance() {
    const result = await signedRead()
    if (result !== undefined) {
      setBalance(result.toString())
    }
  }

  return (
    <div>
      <button onClick={fetchBalance} disabled={isLoading}>
        {isLoading ? 'Reading...' : 'Get Balance'}
      </button>
      {balance && <p>Balance: {balance}</p>}
      {error && <p>Error: {error.message}</p>}
    </div>
  )
}
```

### Loading state handling

```typescript
import { useSignedReadContract } from 'seismic-react'

function ReadWithLoadingState() {
  const { signedRead, isLoading, error } = useSignedReadContract({
    address: CONTRACT_ADDRESS,
    abi,
    functionName: 'getSecret',
  })

  return (
    <div>
      <button onClick={signedRead} disabled={isLoading}>
        {isLoading ? 'Fetching...' : 'Read Secret'}
      </button>
      {isLoading && <span>Please wait, signing and decrypting...</span>}
    </div>
  )
}
```

### Error handling

```typescript
import { useSignedReadContract } from 'seismic-react'

function ReadWithErrorHandling() {
  const { signedRead, error } = useSignedReadContract({
    address: CONTRACT_ADDRESS,
    abi,
    functionName: 'balanceOf',
  })

  async function handleRead() {
    try {
      const result = await signedRead()
      console.log('Result:', result)
    } catch (e) {
      console.error('Signed read failed:', e)
    }
  }

  return (
    <div>
      <button onClick={handleRead}>Read</button>
      {error && <p style={{ color: 'red' }}>Last error: {error.message}</p>}
    </div>
  )
}
```

{% hint style="info" %}
Unlike wagmi's `useReadContract` which auto-fetches on mount, `useSignedReadContract` returns a function you call imperatively. This is because signed reads require wallet interaction to prove caller identity.
{% endhint %}

## See Also

* [useShieldedWriteContract](https://docs.seismic.systems/clients/typescript/react/hooks/useshieldedwrite.md) -- Send encrypted write transactions
* [useShieldedContract](https://docs.seismic.systems/clients/typescript/react/hooks/useshieldedcontract.md) -- Contract instance with both read and write methods
* [useShieldedWallet](https://docs.seismic.systems/clients/typescript/react/hooks/useshieldedwallet.md) -- Access the underlying wallet client
* [ShieldedWalletProvider](https://docs.seismic.systems/clients/typescript/react/shielded-wallet-provider.md) -- Context provider required by this hook
* [Hooks Overview](https://docs.seismic.systems/clients/typescript/react/hooks.md) -- Summary of all hooks


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.seismic.systems/clients/typescript/react/hooks/useshieldedread.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
