hytopia-steaks
v1.1.7
Published
HYTOPIA staking contract analyzer for stakable tokens within the HYTOPIA ecosystem.
Downloads
218
Maintainers
Readme
Dependencies
Getting Started
Install the library
npm install hytopia-steaks
Roadmap
- [x] Worlds Staking Contract
- [x] HYCHAIN Node Referee Contract
- [x] HYCHAIN Node NFT Contract
- [x] HYCHAIN Delegate Registry Contract
- [ ] Worlds NFT Contract
- [ ] Avatar Staking Contract - TBD
- [ ] Avatar NFT Contract
- [ ] LP Staking Contract - TBD
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.
Create a .env file from the
.env.example
Run the integration tests:
npm run test:integration