Gathering detailed insights and metrics for @hashup-it/hashup-react-sdk
Gathering detailed insights and metrics for @hashup-it/hashup-react-sdk
Gathering detailed insights and metrics for @hashup-it/hashup-react-sdk
Gathering detailed insights and metrics for @hashup-it/hashup-react-sdk
npm install @hashup-it/hashup-react-sdk
Typescript
Module System
Min. Node Version
Node Version
NPM Version
68.2
Supply Chain
93.5
Quality
74.7
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Total Downloads
2,426
Last Day
1
Last Week
5
Last Month
29
Last Year
415
2 Stars
16 Commits
1 Watchers
1 Branches
4 Contributors
Updated on Feb 11, 2023
Minified
Minified + Gzipped
Latest Version
0.1.13
Package Id
@hashup-it/hashup-react-sdk@0.1.13
Unpacked Size
111.80 kB
Size
14.54 kB
File Count
66
NPM Version
8.15.0
Node Version
16.18.1
Published on
Mar 13, 2023
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
66.7%
5
Compared to previous week
Last Month
-69.1%
29
Compared to previous month
Last Year
-28.7%
415
Compared to previous year
1
This is official HashUp protocol SDK for React. You can use it to make your own marketplace using our protocol.
1# Using NPM 2npm install @hashup-it/hashup-react-sdk 3 4# Using Yarn 5yarn add @hashup-it/hashup-react-sdk
At top of the file import useHashup
hook from our SDK.
1import { useHashup } from "@hashup-it/hashup-react-sdk"
Now declare it in your component
1function App() { 2 3 const { buyGame } = useHashup() 4 5 return (<div className="App">/*Your app code*/</div>) 6}
setMarketplace()
functionaccepts a single argument:
1...
2const { setMarketplace } = useHashup()
3
4function handleSetMarketplace() {
5 const marketplace = "0x714EF5c429ce9bDD0cAC3631D30474bd04e954Dc"; // Overwrite the default HashUp marketplace with yours
6
7 setMarketplace(marketplace)
8}
9
10...
Sets up your marketplace address.
buyGame()
functionaccepts two arguments:
1...
2const { buyGame } = useHashup()
3
4function handleBuy() {
5 const license = "0x6cbf4648d1f326585f7aa768913991efc0f2b952" // Specify address of license you want to buy
6 const amount = "200" // Specify amount of license you want to buy
7
8 buyGame(license, amount)
9}
10
11...
Clicking on button will now open MetaMask window. If user is not connected it will ask him to connect, then request
approve (if needed).
After successfull approval it will request license buy transaction. It will take specified amount of USDT from user
account and send licenses to his wallet.
setReferrer()
functionaccepts a single argument:
1...
2const { setReferrer } = useHashup()
3
4function handleSetReferrer() {
5 const referrer = "0x486dFb71b0CaB4f16Aa760b868EBaFF17f0a6535"; // Set a
6
7 setReferrer(referrer)
8}
9
10...
Sets up an address of someone referring a purchase.
Example use case: A person generates a referral link pointing to your website. Then, some other person after clicking it purchases a game, automatically triggering a referral action (handled by our protocol) along with the transaction.
approve()
function1... 2const { approve } = useHashup() 3 4function handleApprove() { 5 approve() 6} 7 8...
Triggers manual payment token approval.
Example use case:
1interface UseHashupOutput { 2 /** 3 * Allows for ahead-of-time payment approval. Called automatically by `buyGame()`. 4 */ 5 approve: () => Promise<void> 6 7 /** 8 * Purchases a license. Defaults to one token bought, i.e. 100 units. 9 * @param address address of ERC20 licence about to be bought 10 * @param amount amount of token units bought (unit is 0.01 of a token) 11 */ 12 buyGame: (address: string, amount?: string) => Promise<string | void> 13 14 /** 15 * HashUp-protocol lifecycle state. Affected by `buyGame()` method call. 16 * @default BuyStage.NOT_STARTED 17 */ 18 buyingStage: BuyStage 19 20 /** 21 * HashUp-protocol wallet connection init status 22 */ 23 isEthereumLoading: boolean 24 25 /** 26 * HashUp-protocol network compatibility status 27 */ 28 isNetworkValid: boolean 29 30 /** 31 * Sets a custom marketplace. Defaults to HashUp. 32 * @param marketplace marketplace's blockchain address 33 */ 34 setMarketplace: React.Dispatch<React.SetStateAction<string>> 35 36 /** 37 * Sets a reflink variable. Affects `buyGame()` method call. 38 * @param referrer purchase referrer's blockchain address 39 */ 40 setReferrer: React.Dispatch<React.SetStateAction<string>> 41}
yarn install
yarn build
npm publish --access public
All games listed on HashUp protocol are available at https://open-api.hashup.it/v1/tokens endpoint of our public API.
For example:
https://open-api.hashup.it/v1/tokens/<chain|chainId>
– to get all polygon tokens
example: https://open-api.hashup.it/v1/tokens/137/https://open-api.hashup.it/v1/token/<chain|chainId>/<address>
– to get a specific token
example: https://open-api.hashup.it/v1/token/137/0x6cbf4648d1f326585f7aa768913991efc0f2b952You can check full API specification at wiki.hashup.it.
No vulnerabilities found.
No security vulnerabilities found.