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

hytopia-steaks

v1.1.7

Published

HYTOPIA staking contract analyzer for stakable tokens within the HYTOPIA ecosystem.

Downloads

218

Readme

Dependencies

ethers.js v6

Getting Started

Install the library

npm install hytopia-steaks

Roadmap

API

The APIs are a thin wrapper around the contracts designed to get you up and going quickly when directly interacting with the contracts.

HYCHAIN Node Referee API

Create instance of the Node Referee contract.

This is the contract responsible for emitting rewards for the HYCHAIN Guardian Nodes.

    import { ethers } from 'ethers'
    import { getHYCHAINNodeRefereeContract } from 'hytopia-steaks/contracts/hychain-node-referee-contract'
    import { HYCHAINNodeRefereeAPI } from 'hytopia-steaks'

    const provider = new ethers.JsonRpcProvider('https://hychain.calderachain.xyz/http')
    const contact = getHYCHAINNodeRefereeContract(provider)
    const api = new HYCHAINNodeRefereeAPI(contact)

Get total rewards claimable for node key IDs

    const batchedRewards = await api.claimableNodeKeyRewards([
      100, 101, 102
    ])

    console.log(batchedRewards)
    // [213123123, 1312312312, 23434534433] $TOPIA

Get total rewards claimed for node key IDs

    const batchedRewards = await api.claimedNodeKeyRewardsBatched([
      100, 101, 102
    ])

    console.log(batchedRewards)
    // [3142313123, 53453453535, 2131342344] $TOPIA

Get the total assertions made by the node key token ID

    const assertionCount = await api.totalNodeKeyAssertions(100)

    console.log(assertionCount)
    // 12

HYCHAIN Node NFT API

Create instance of the Node NFT contract

    import { ethers } from 'ethers'
    import { getHYCHAINNodeNFTContract } from 'hytopia-steaks/contracts/hychain-node-key-contract'
    import { HYCHAINNodeKeyAPI } from 'hytopia-steaks'

    const provider = new ethers.JsonRpcProvider('https://hychain.calderachain.xyz/http')
    const contact = getHYCHAINNodeNFTContract(provider)
    const api = new HYCHAINNodeKeyAPI(contact)

Get balance of Node keys by address

    const nodeKeyOwnedCount = await api.balanceOf('0x122690b8525e6b33f38ff34bdd7644676d9d46d8')

    console.log(nodeKeyOwnedCount)
    // 3

Get Node key owner for token ID

    const owner = await api.getNodeKeyOwner(2)

    console.log(owner)
    // 0x122690b8525e6b33f38ff34bdd7644676d9d46d8

World API

Create instance of the WorldEscrowAPI

    import { ethers } from 'ethers'
    import { getWorldEscrowContract } from 'hytopia-steaks/contracts/world-escrow-contract'
    import { WorldEscrowAPI } from 'hytopia-steaks'

    const provider = new ethers.InfuraProvider("mainnet", "<Your Infura Project ID>")
    const contract = getWorldEscrowContract(provider)
    const api = new WorldEscrowAPI(contract)

World info by token ID with owner and associated metadata

    const worldInfo = await api.getWorldInfo(999)

    console.log(worldInfo)
    // {
    //    // weight based on rarity
    //     weight: 123
    //
    //     // staked to, otherwise owner == 0
    //     owner: "0x12345"
    // }

Check total claimable $TOPIA user rewards by address

    const rewards = await api.checkUserRewards('0x12345')

    console.log(rewards)
    // 2131242345243 $TOPIA

Get staked tokens by user address

    const tokenIds = await api.getUserStakedTokens('0x12345')

    console.log(tokenIds)
    // [123, 456, 999]

Get all staked tokens by events

    const events = api.getAllStakedTokensByEvents()

    console.log(events)
    // [
    //    {
    //        tokenId: 3000,
    //        owner: "0xE08",
    //        blockNumber: 500,
    //        blockHash: "0x1235",
    //        transactionHash: "0x1236",
    //        removed: false,
    //    },
    //    {
    //        tokenId: 4000,
    //        owner: "0xE09",
    //        blockNumber: 501,
    //        blockHash: "0x1235",
    //        transactionHash: "0x1236",
    //        removed: false,
    //    },
    //    ...
    // ]

Contributing

If you are interested in contributing then please feel free to clone and submit PRs against main. All status checks must pass and code coverage is required for both integration tests and unit tests.

Running the unit tests

npm run test

Running the integration tests

In order to run the integration tests locally you must provide an INFURA API key along with a few .env variables.

  1. Create a .env file from the .env.example

  2. Run the integration tests:

    • npm run test:integration