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

# useShieldedWallet

Hook that consumes the `ShieldedWalletProvider` context. Returns the shielded public client, wallet client, connected address, error state, and a loaded flag indicating whether initialization is complete.

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

## Return Type

| Property       | Type                           | Description                                         |
| -------------- | ------------------------------ | --------------------------------------------------- |
| `publicClient` | `ShieldedPublicClient \| null` | Shielded public client for reads                    |
| `walletClient` | `ShieldedWalletClient \| null` | Shielded wallet client for writes                   |
| `address`      | `Hex \| null`                  | Connected wallet address                            |
| `error`        | `string \| null`               | Error message if initialization failed              |
| `loaded`       | `boolean`                      | Whether the wallet client has finished initializing |

***

## Usage

### Basic

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

function WalletInfo() {
  const { address, walletClient, publicClient } = useShieldedWallet()

  if (!walletClient) return <div>Connect your wallet</div>

  return <div>Connected: {address}</div>
}
```

### Handling loading state

The `loaded` flag is `false` until the shielded clients have been fully initialized. Use it to avoid rendering components that depend on the wallet client before it is ready.

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

function App() {
  const { loaded, walletClient, address } = useShieldedWallet()

  if (!loaded) {
    return <div>Initializing shielded wallet...</div>
  }

  if (!walletClient) {
    return <div>Please connect your wallet</div>
  }

  return <div>Wallet ready: {address}</div>
}
```

### Error handling

If initialization fails (for example, the node is unreachable or the wallet connector is incompatible), the `error` field contains the error message.

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

function WalletStatus() {
  const { loaded, error, walletClient } = useShieldedWallet()

  if (!loaded) return <div>Loading...</div>
  if (error) return <div>Error: {error}</div>
  if (!walletClient) return <div>Not connected</div>

  return <div>Wallet connected</div>
}
```

### Accessing clients for direct seismic-viem calls

The returned `publicClient` and `walletClient` are full seismic-viem client instances. You can use them directly for operations not covered by the higher-level hooks.

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

function DirectClientUsage() {
  const { publicClient, walletClient } = useShieldedWallet()

  async function getBlockNumber() {
    if (!publicClient) return
    const block = await publicClient.getBlockNumber()
    console.log('Current block:', block)
  }

  async function sendRawTransaction() {
    if (!walletClient) return
    const hash = await walletClient.sendTransaction({
      to: '0x...',
      value: 0n,
    })
    console.log('Transaction hash:', hash)
  }

  return (
    <div>
      <button onClick={getBlockNumber}>Get Block</button>
      <button onClick={sendRawTransaction}>Send Tx</button>
    </div>
  )
}
```

{% hint style="warning" %}
This hook must be used within a `ShieldedWalletProvider`. It will throw if called outside the provider tree.
{% endhint %}

## See Also

* [ShieldedWalletProvider](/clients/typescript/react/shielded-wallet-provider.md) -- Context provider that supplies the shielded clients
* [useShieldedContract](/clients/typescript/react/hooks/useshieldedcontract.md) -- Create a contract instance using the wallet client
* [useShieldedWriteContract](/clients/typescript/react/hooks/useshieldedwrite.md) -- Send encrypted write transactions
* [useSignedReadContract](/clients/typescript/react/hooks/useshieldedread.md) -- Perform signed, encrypted read calls
* [Hooks Overview](/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 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/useshieldedwallet.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.
