# useApproveERC20

## Function: useApproveERC20()

> **useApproveERC20**(`tokenAddress`, `contractAddress`, `amount`?, `chainId`?, `enabled`?): `object`

A custom hook for managing ERC-20 token approval to a specific contract. This hook includes functionality to check the current allowance, simulate the approval transaction, execute the approval, and track its status.

### Parameters

#### tokenAddress

\`0x${string}\`

The address of the ERC-20 token to be approved.

#### contractAddress

\`0x${string}\`

The address of the contract to which the token is being approved.

#### amount?

`bigint`

The amount of tokens to approve. If not provided, it defaults to `0n`.

#### chainId?

`number`

The ID of the blockchain network where the ERC-20 token resides.

#### enabled?

`boolean` = `true`

A flag to enable or disable the hook's functionality. When `false`, all queries and actions are disabled.

### Returns

`object`

An object containing the following

#### allowance

> **allowance**: `undefined` | `bigint`

#### approve()

> **approve**: () => `void`

**Returns**

`void`

#### approveError

> **approveError**: `null` | `WriteContractErrorType`

#### approveLoading

> **approveLoading**: `boolean`

#### approveSuccess

> **approveSuccess**: `boolean`

#### approveTxLoading

> **approveTxLoading**: `boolean`

#### approveTxSuccess

> **approveTxSuccess**: `boolean`

### Defined in

[packages/wagmi/src/hook/useApproveERC20.tsx:19](https://github.com/haven1network/haven1-sdk/blob/df6267fec7b75040411529269f9c6a88e9c756ee/packages/wagmi/src/hook/useApproveERC20.tsx#L19)


---

# Agent Instructions: 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:

```
GET https://docs.haven1.org/build/developer-tools/haven1-sdk/haven1-wagmi-sdk/hook-module/useapproveerc20.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
