> For the complete documentation index, see [llms.txt](https://docs.haven1.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.haven1.org/build/developer-tools/haven1-sdk/haven1-wagmi-sdk/hook-module.md).

# Hook Module

This module provides custom React hooks for interacting with blockchain data and events. These hooks are designed to simplify the process of fetching and managing blockchain-related data within React applications.

## Features

* Custom hooks for blockchain data fetching.
* Easy integration with React components.
* Support for various blockchain operations.

## Available Hooks

* `useBalance`: Fetches the balance of a specified token for a given wallet address.
* `useWatch`: Watches for changes in blockchain data and updates the component state accordingly.
* `useApproveERC20`: Manages ERC-20 token approval to a specific contract.
* `useContractWrite`: Handles writing to a smart contract with various configurations.

## Usage

Import the necessary hooks from this module to use them in your React components. These hooks provide a simple API to interact with blockchain data and handle state management efficiently.

## Usage Example

Here is an example of how to use the `useBalance` hook in a React component:

```tsx
import React from 'react';
import { useBalance } from '@haven1/wagmi-sdk/hook';

const BalanceComponent = ({ address, tokenAddress }) => {
  const balance = useBalance(address, tokenAddress);

  return (
    <div>
      <h3>Token Balance</h3>
      {balance ? (
        <p>
          {balance.formatted} {balance.symbol}
        </p>
      ) : (
        <p>Loading...</p>
      )}
    </div>
  );
};

export default BalanceComponent;
```

In this example, the `useBalance` hook is used to fetch the balance of a specified token for a given wallet address. The balance is then displayed in the component.


---

# 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.haven1.org/build/developer-tools/haven1-sdk/haven1-wagmi-sdk/hook-module.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.
