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.