> 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

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](/clients/typescript/react/hooks/useshieldedwallet.md)       | Access shielded wallet and public clients from context |
| [useShieldedContract](/clients/typescript/react/hooks/useshieldedcontract.md)   | Get a ShieldedContract instance for reads and writes   |
| [useShieldedWriteContract](/clients/typescript/react/hooks/useshieldedwrite.md) | Send encrypted write transactions                      |
| [useSignedReadContract](/clients/typescript/react/hooks/useshieldedread.md)     | Execute authenticated read calls                       |

## See Also

* [ShieldedWalletProvider](/clients/typescript/react/shielded-wallet-provider.md) -- Context provider required by all hooks
* [Installation](/clients/typescript/react/installation.md) -- Package setup and peer dependencies
* [Seismic React Overview](/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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
