USE-HATHORPAY
npm package for interacting with hathorpay extension - current version 0.0.9

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:
1
import React from 'react'
2
import {
3
connect,
4
disconnect,
5
getBalance,
6
getTokenOwnerStatus,
7
getWalletVersion
8
} from 'use-hathorpay'
9
​
10
const YourComponent = () => {
11
...
12
const connectCallback = (response) => {
13
if (response['status']) {
14
// do your action
15
...
16
}
17
}
18
19
const handleConnectWallet = () => {
20
connect(connectCallback);
21
}
22
23
const disconnectCallback = (response) => {
24
if (response['status']) {
25
// do your action
26
...
27
}
28
}
29
30
const handleDisconnectWallet = () => {
31
disconnect(disconnectCallback);
32
}
33
34
const getBalanceCallback = (response) => {
35
if (response['status']) {
36
// do your action
37
...
38
}
39
}
40
41
const handleGetBalance = (tokenUid) => {
42
// tokenUid: "" or "00" for getting htr balance
43
// tokenUid for token balance
44
getBalance(tokenUid, getBalanceCallback);
45
}
46
47
const getTokenOwnerStatusCallback = (response) => {
48
if (response['status']) {
49
// do your action
50
...
51
}
52
}
53
54
const handleGetTokenOwnerStatus = (tokenUid) => {
55
getTokenOwnerStatus(tokenUid, getTokenOwnerStatusCallback);
56
}
57
58
const getWalletVersionCallback = (response) => {
59
if (response['status']) {
60
// do your action
61
...
62
}
63
}
64
65
const handleGetWalletVersion = () => {
66
getWalletVersion(getWalletVersionCallback);
67
}
68
}
69
​
Copied!

Special thanks

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

Keywords

hathorpay, htr, hathor, use-hathorpay, hathor network
Last modified 19d ago