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

@blockcoders/harmony-providers

v1.0.0

Published

This library provides a collection of methods to interact with the Harmony blockchain.

Downloads

4

Readme

Harmony RPC Providers

This library provides a collection of methods to interact with the Harmony blockchain.

Currently under developement 🤓

Install

npm i @blockcoders/harmony-providers

Usage

Node

// JavaScript
const { HarmonyProvider } = require('@blockcoders/harmony-providers')

// TypeScript
import { HarmonyProvider } from '@blockcoders/harmony-providers'

Harmony SDK

Expected Methods: | Method | Description | | ------------- | ------------- | | getBlockNumber | Gets the last block number. | | getBlock | Gets the block data by block number or block hash (retrieves transactions hashes only). | | getBlockWithTransactions | Gets the block data by block number or block hash and retrieve the transactions data. | | getTransaction | Gets the transaction data by transaction hash. |

Initializing

import { HarmonyProvider, HMY_TESTNET_NETWORK } from '@blockcoders/harmony-providers'

const provider = new HarmonyProvider(HMY_TESTNET_NETWORK) // Use HMY_NETWORK to interact with Harmony's mainnet

Methods

getBlockNumber

Returns the last block number on the blockchain.

import { HarmonyProvider, HarmonyProviderMethods, HMY_TESTNET_NETWORK } from '@blockcoders/harmony-providers'

const provider = new HarmonyProvider(HMY_TESTNET_NETWORK)
const blockNumber = await provider.getBlockNumber()
// Executing the perform method 
const otherWayToGetBlockNumber = await provider.perform(HarmonyProviderMethods.getBlockNumber, {})

getBlock and getBlockWithTransactions

Returns the block data. The block can be searched by it's hash or number. It can retrieve the block transactions data or just the transactions hashes.

import { HarmonyProvider, HarmonyProviderMethods, HMY_TESTNET_NETWORK } from '@blockcoders/harmony-providers'

const provider = new HarmonyProvider(HMY_TESTNET_NETWORK)

// Searching with number

const searchByTag = "0x47db8e" // The block number can be an hexadecimal, number or "latest"
const block = await provider.getBlock(searchByTag)
const blockWithTransactionsData = await provider.getBlockWithTransactions(searchByTag)

// Searching with hash

const searchByHash = "0xd5258b03ae6b7d1ad8e932bf1aed6257241101e98be7ac6dab74013f267596de"
const sameBlock = await provider.getBlock(searchByHash)
const sameBlockWithTransactionsData = await provider.getBlockWithTransactions(searchByHash)

// Using perform
const params = {
    blockTag: "0x47db8e", // Change this property for blockHash if you want touse the hash to search the block
    includeTransactions: true // This will indicate the method whether or not to get the transactions data
}
const someBlock = await provider.perform(HarmonyProviderMethods.getBlock, params)

getTransaction

Returns the transaction data by hash.

import { HarmonyProvider, HarmonyProviderMethods, HMY_TESTNET_NETWORK } from '@blockcoders/harmony-providers'

const provider = new HarmonyProvider(HMY_TESTNET_NETWORK)

const txHash = "0x371ec289c5973c16d58cf600f8f2ce040fe8b429a6007976040d55a1759b8993"
const transaction = await provider.getTransaction(txHash)

// Executing the perform method 
const params = {
    transactionHash: "0x371ec289c5973c16d58cf600f8f2ce040fe8b429a6007976040d55a1759b8993"
}
const otherWayToGetBlockNumber = await provider.perform(HarmonyProviderMethods.getTransaction, params)

Change Log

See Changelog for more information.

Contributing

Contributions welcome! See Contributing.

Collaborators

Acknowledgements

This project was kindly sponsored by Harmony.

License

Licensed under the MIT - see the LICENSE file for details.