npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hashup-it/hashup-react-sdk

v0.1.13

Published

This is official HashUp protocol SDK for React. You can use it to make your own marketplace using our protocol.

Downloads

20

Readme

HashUp SDK for React

This is official HashUp protocol SDK for React. You can use it to make your own marketplace using our protocol.

Installation

# Using NPM  
npm install @hashup-it/hashup-react-sdk

# Using Yarn  
yarn add @hashup-it/hashup-react-sdk

Usage

At top of the file import useHashup hook from our SDK.

import { useHashup } from "@hashup-it/hashup-react-sdk"  

Now declare it in your component

function App() {

	const { buyGame } = useHashup()

	return (<div className="App">/*Your app code*/</div>)
}  

setMarketplace() function

accepts a single argument:

  • address of your own marketplace
...
const { setMarketplace } = useHashup()

function handleSetMarketplace() {
	const marketplace = "0x714EF5c429ce9bDD0cAC3631D30474bd04e954Dc"; // Overwrite the default HashUp marketplace with yours

	setMarketplace(marketplace)
}

...

Sets up your marketplace address.


buyGame() function

accepts two arguments:

  • ERC20 token address of license you want to buy
  • [how many licenses you want to buy]
  • [game metadata to auto-save the token in user's wallet]
...
const { buyGame } = useHashup()

function handleBuy() {
	const license = "0x6cbf4648d1f326585f7aa768913991efc0f2b952" // Specify address of license you want to buy
	const amount = "200" // Specify amount of license you want to buy  

	buyGame(license, amount)
}

...

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() function

accepts a single argument:

  • address of the transaction referrer
...
const { setReferrer } = useHashup()

function handleSetReferrer() {
	const referrer = "0x486dFb71b0CaB4f16Aa760b868EBaFF17f0a6535"; // Set a 

	setReferrer(referrer)
}

...

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() function

...
const { approve } = useHashup()

function handleApprove() {
	approve()
}

...

Triggers manual payment token approval. Example use case:

Hook Interface

interface UseHashupOutput {
    /**
     * Allows for ahead-of-time payment approval. Called automatically by `buyGame()`.
     */
    approve: () => Promise<void>

    /**
     * Purchases a license. Defaults to one token bought, i.e. 100 units.
     * @param address address of ERC20 licence about to be bought
     * @param amount amount of token units bought (unit is 0.01 of a token)
     */
    buyGame: (address: string, amount?: string) => Promise<string | void>

    /**
     * HashUp-protocol lifecycle state. Affected by `buyGame()` method call.
     * @default BuyStage.NOT_STARTED
     */
    buyingStage: BuyStage

    /**
     * HashUp-protocol wallet connection init status
     */
    isEthereumLoading: boolean

    /**
     * HashUp-protocol network compatibility status
     */
    isNetworkValid: boolean

    /**
     * Sets a custom marketplace. Defaults to HashUp.
     * @param marketplace marketplace's blockchain address
     */
    setMarketplace: React.Dispatch<React.SetStateAction<string>>

    /**
     * Sets a reflink variable. Affects `buyGame()` method call.
     * @param referrer purchase referrer's blockchain address
     */
    setReferrer: React.Dispatch<React.SetStateAction<string>>
}

Class Diagram

hashup-react-sdk UML

Building

  1. yarn install
  2. revision bump
  3. yarn build
  4. npm publish --access public

Where to get license data?

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/0x6cbf4648d1f326585f7aa768913991efc0f2b952

You can check full API specification at wiki.hashup.it.