> For the complete documentation index, see [llms.txt](https://hathor-federation.gitbook.io/use-hathorpay-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hathor-federation.gitbook.io/use-hathorpay-docs/use-hathorpay.md).

# 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
