> 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.md).

# Hooks

React hooks for shielded transactions and signed reads

seismic-react provides four hooks that mirror wagmi's hook API but route through Seismic's shielded transport layer. Each hook wraps the corresponding seismic-viem client or contract method, handling encryption, signing, and decryption automatically.

## Hook Comparison

| seismic-react Hook         | wagmi Equivalent                 | Purpose                                   |
| -------------------------- | -------------------------------- | ----------------------------------------- |
| `useShieldedWallet`        | `useAccount` + `useWalletClient` | Access shielded public and wallet clients |
| `useShieldedContract`      | `useContract`                    | Get a ShieldedContract instance           |
| `useShieldedWriteContract` | `useWriteContract`               | Send encrypted write transactions         |
| `useSignedReadContract`    | `useReadContract`                | Execute authenticated read calls          |

{% hint style="info" %}
All hooks require `ShieldedWalletProvider` context. Calling any hook outside the provider tree will throw an error.
{% endhint %}

## Common Patterns

### Wallet check

Always verify the wallet is loaded before calling contract methods:

```typescript
const { walletClient, loaded } = useShieldedWallet()

if (!loaded) return <div>Loading wallet...</div>
if (!walletClient) return <div>Please connect your wallet</div>
```

### Loading states

The write and read hooks expose `isLoading` so you can disable buttons or show spinners:

```typescript
const { writeContract, isLoading } = useShieldedWriteContract({ address, abi, functionName: 'transfer', args })

return (
  <button onClick={writeContract} disabled={isLoading}>
    {isLoading ? 'Sending...' : 'Transfer'}
  </button>
)
```

### Error handling

Every hook returns an `error` field. Check it after operations complete:

```typescript
const { signedRead, error } = useSignedReadContract({
  address,
  abi,
  functionName: "balanceOf",
});

async function fetchBalance() {
  const result = await signedRead();
  if (error) {
    console.error("Read failed:", error.message);
  }
}
```

## Pages

| Page                                                                                                        | Description                                            |
| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| [useShieldedWallet](https://docs.seismic.systems/clients/typescript/react/hooks/useshieldedwallet.md)       | Access shielded wallet and public clients from context |
| [useShieldedContract](https://docs.seismic.systems/clients/typescript/react/hooks/useshieldedcontract.md)   | Get a ShieldedContract instance for reads and writes   |
| [useShieldedWriteContract](https://docs.seismic.systems/clients/typescript/react/hooks/useshieldedwrite.md) | Send encrypted write transactions                      |
| [useSignedReadContract](https://docs.seismic.systems/clients/typescript/react/hooks/useshieldedread.md)     | Execute authenticated read calls                       |

## See Also

* [ShieldedWalletProvider](https://docs.seismic.systems/clients/typescript/react/shielded-wallet-provider.md) -- Context provider required by all hooks
* [Installation](https://docs.seismic.systems/clients/typescript/react/installation.md) -- Package setup and peer dependencies
* [Seismic React Overview](https://docs.seismic.systems/clients/typescript/react.md) -- SDK architecture and quick start


---

# 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.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.
