---
description: npm package for interacting with hathorpay extension - current version 0.1.2
---

# 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
