🚀
HathorPay Developer Documentation
  • USE-HATHORPAY
  • Functions
    • API Reference
      • connect
      • disconnect
      • getBalance
      • getConnectionStatus
      • getSignature
      • getTokenOwnerStatus
      • getWalletVersion
      • isHathorpayAvailable
      • sendToken
      • verifySignature
  • More features coming soon
Powered by GitBook
On this page
  • Welcome to use-hathorpay
  • Usage
  • Special thanks
  • Keywords

USE-HATHORPAY

npm package for interacting with hathorpay extension - current version 0.1.2

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

Keywords

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

NextAPI Reference

Last updated 3 years ago

use-hathorpay is a built by , the development team behind .

HTRFDT
HathorPay