# USE-HATHORPAY

## Welcome to use-hathorpay

use-hathorpay allows dapp users of Hathor Network to connect to the HathorPay extension in a way that is straightforward and easy for developers. It provides a common data structure for any connected account and it aims to provide some features that are often reimplemented by dapp developers: connecting to a wallet, fetching balances, addresses, and much more.

## Usage

Add it to your project

> npm i use-hathorpay

or

> yarn add use-hathorpay

Use it in your React app:

```
import React from 'react'
import { 
    connect, 
    disconnect, 
    getBalance, 
    getTokenOwnerStatus, 
    getWalletVersion 
} from 'use-hathorpay'

const YourComponent = () => {
    ...
    const connectCallback = (response) => {
        if (response['status']) {
            // do your action
            ...
        }
    }
    
    const handleConnectWallet = () => {
        connect(connectCallback);
    }
    
    const disconnectCallback = (response) => {
        if (response['status']) {
            // do your action
            ...
        }
    }
    
    const handleDisconnectWallet = () => {
        disconnect(disconnectCallback);
    }
    
    const getBalanceCallback = (response) => {
        if (response['status']) {
            // do your action
            ...
        }
    }
    
    const handleGetBalance = (tokenUid) => {
        // tokenUid: "" or "00" for getting htr balance
        // tokenUid for token balance
        getBalance(tokenUid, getBalanceCallback);
    }
    
    const getTokenOwnerStatusCallback = (response) => {
        if (response['status']) {
            // do your action
            ...
        }
    }
    
    const handleGetTokenOwnerStatus = (tokenUid) => {
        getTokenOwnerStatus(tokenUid, getTokenOwnerStatusCallback);
    }
    
    const getWalletVersionCallback = (response) => {
        if (response['status']) {
            // do your action
            ...
        }
    }
    
    const handleGetWalletVersion = () => {
        getWalletVersion(getWalletVersionCallback);
    }
}

```

## Special thanks

use-hathorpay is a built by [HTRFDT](https://htrfdt.com), the development team behind [HathorPay](https://hathorpay.com).

## Keywords

hathorpay, htr, hathor, use-hathorpay, hathor network


---

# 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://hathor-federation.gitbook.io/use-hathorpay-docs/use-hathorpay.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.
