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

my-hedera

v1.0.4

Published

My Hedera Command Line Tool

Downloads

2

Readme

Introduction

This command line tool is an experimentation to see how interesting and easy we could use command line to interact with the Hedera platform. As of today, this tools allows you only to get a balance or to send hBars to someone else.

Requirements

You'll need obviously npm to install it. You can refer to the NodeJS documentation to know how to install it:

https://nodejs.org/en/download/package-manager/

When that's done, just type:

npm i -g my-hedera

It will install the command line my-hedera on your computer. When you are done, you should be able to run:

$ my-hedera -h
  __  __         _   _          _                _ _
 |  \/  |_   _  | | | | ___  __| | ___ _ __ __ _| | |
 | |\/| | | | | | |_| |/ _ \/ _` |/ _ \ '__/ _` | | |
 | |  | | |_| | |  _  |  __/ (_| |  __/ | | (_| |_|_|
 |_|  |_|\__, | |_| |_|\___|\__,_|\___|_|  \__,_(_|_)
         |___/                                       
Welcome to Hedera!
Java Version: 11.02
usage: my-hedera
 -a,--account <arg>   Your account number to use the Hedera network (you
                      can as well use the environment variable
                      MYHEDERA_ACCOUNTNUM)
 -b,--balance <arg>   Account number you want to get the balance
 -h,--help            print this message
 -k,--key <arg>       Your private key to use the Hedera network (you can
                      as well use the environment variable
                      MYHEDERA_OPERATORKEY)
 -n,--node <arg>      List of nodes that you would like to connect. The
                      syntax must be this one: <NODE ID>:<IP OR SERVER
                      NAME>:<PORT> (example for the node 0.0.3 on the main
                      net: 3:35.237.200.180:50211
 -s,--send <arg>      Account number you want to send tinybars
 -t,--tiny <arg>      Amount of tinybars to send

Be aware that this package is just a bundle of a JAR file that I created. Why Java? Because the Java SDK is today the only maintained by Hedera. The consequence is that you'll need Java 11 running on your computer. If not, you'll get a message like this:

$ my-hedera -h
  __  __         _   _          _                _ _
 |  \/  |_   _  | | | | ___  __| | ___ _ __ __ _| | |
 | |\/| | | | | | |_| |/ _ \/ _` |/ _ \ '__/ _` | | |
 | |  | | |_| | |  _  |  __/ (_| |  __/ | | (_| |_|_|
 |_|  |_|\__, | |_| |_|\___|\__,_|\___|_|  \__,_(_|_)
         |___/                                       
Welcome to Hedera!
Java Version: 1.80121
Unfortunately, you need Java 11...

You'll find an easy documentation to follow on how to install Java here:

https://java.com/en/download/help/download_options.xml

Usage

Let's start by checking my balance. My account ID is 0.0.2211, so if you type this command, it will ask to authenticate against the network:

$ my-hedera -b 2211
  __  __         _   _          _                _ _
 |  \/  |_   _  | | | | ___  __| | ___ _ __ __ _| | |
 | |\/| | | | | | |_| |/ _ \/ _` |/ _ \ '__/ _` | | |
 | |  | | |_| | |  _  |  __/ (_| |  __/ | | (_| |_|_|
 |_|  |_|\__, | |_| |_|\___|\__,_|\___|_|  \__,_(_|_)
         |___/                                       
Welcome to Hedera!
Java Version: 11.02
The option -a is required. Please specify your account number or set the environment variable MYHEDERA_ACCOUNTNUM.

You can pass the authentication in the command line tool:

$ my-hedera -b 2211 -a <YOUR ACCOUNT NUMBER ONLY> -key <YOUR PRIVATE KEY>

Or just using environment variables:

export MYHEDERA_ACCOUNTNUM=2211
export MYHEDERA_OPERATORKEY=xxx

I prefer this option, like that, I'm not required to provide it for each call. And you should get:

$ my-hedera -b 2211
  __  __         _   _          _                _ _
 |  \/  |_   _  | | | | ___  __| | ___ _ __ __ _| | |
 | |\/| | | | | | |_| |/ _ \/ _` |/ _ \ '__/ _` | | |
 | |  | | |_| | |  _  |  __/ (_| |  __/ | | (_| |_|_|
 |_|  |_|\__, | |_| |_|\___|\__,_|\___|_|  \__,_(_|_)
         |___/                                       
Welcome to Hedera!
Java Version: 11.02
Configuring the Hedera client
   Account ID: 0.0.2211
   Operator Key: ....2371
Nodes
   Node ID: 0.0.   3   Server: 35.237.200.180:50211
   Node ID: 0.0.   4   Server: 35.186.191.247:50211
   Node ID: 0.0.   5   Server: 35.192.2.25:50211
Collecting the balance
   Account ID: 0.0.2211
The balance of the account 0.0.2211 is :
127 802 673 575 tinyBar(s)
OR 1 278.03 hBar(s)

Of course, if you want to donate some hBars to encourage myself to pursue it, feel free ;)

As you can see, by default, the tool connect to the mainnet. If you want to connect to the testnet, just provide the valid sever details like that:

$ my-hedera -b 1237 -n 3:0.testnet.hedera.com:50211 -n 4:1.testnet.hedera.com:50211 -n 5:2.testnet.hedera.com:50211 -n 6:3.testnet.hedera.com:50211
__  __         _   _          _                _ _
|  \/  |_   _  | | | | ___  __| | ___ _ __ __ _| | |
| |\/| | | | | | |_| |/ _ \/ _` |/ _ \ '__/ _` | | |
| |  | | |_| | |  _  |  __/ (_| |  __/ | | (_| |_|_|
|_|  |_|\__, | |_| |_|\___|\__,_|\___|_|  \__,_(_|_)
       |___/                                       
Welcome to Hedera!
Java Version: 11.02
Configuring the Hedera client
 Account ID: 0.0.1274
 Operator Key: ....99fc
Nodes
 Node ID: 0.0.   3   Server: 0.testnet.hedera.com:50211
 Node ID: 0.0.   4   Server: 1.testnet.hedera.com:50211
 Node ID: 0.0.   5   Server: 2.testnet.hedera.com:50211
 Node ID: 0.0.   6   Server: 3.testnet.hedera.com:50211
Collecting the balance
 Account ID: 0.0.1237
The balance of the account 0.0.1237 is :
100 400 901 330 tinyBar(s)
OR 1 004.01 hBar(s)

Note that you don't need to provide all nodes, just one will do if it's running...

Finally, let's see how to send tiny bars. You just need to use -s <RECIPIENT ACCOUNT NUM> and -t <NUMBER OF TINY BARS TO SEND>:

$ my-hedera -s 1238 -t 1 -n 3:0.testnet.hedera.com:50211 -n 4:1.testnet.hedera.com:50211 -n 5:2.testnet.hedera.com:50211 -n 6:3.testnet.hedera.com:50211
  __  __         _   _          _                _ _
 |  \/  |_   _  | | | | ___  __| | ___ _ __ __ _| | |
 | |\/| | | | | | |_| |/ _ \/ _` |/ _ \ '__/ _` | | |
 | |  | | |_| | |  _  |  __/ (_| |  __/ | | (_| |_|_|
 |_|  |_|\__, | |_| |_|\___|\__,_|\___|_|  \__,_(_|_)
         |___/                                       
Welcome to Hedera!
Java Version: 11.02
Configuring the Hedera client
   Account ID: 0.0.1237
   Operator Key: ....ba12
Nodes
   Node ID: 0.0.   3   Server: 0.testnet.hedera.com:50211
   Node ID: 0.0.   4   Server: 1.testnet.hedera.com:50211
   Node ID: 0.0.   5   Server: 2.testnet.hedera.com:50211
   Node ID: 0.0.   6   Server: 3.testnet.hedera.com:50211
Sending hBars
   Recipient Account ID: 0.0.1238
   Amount of tinyBars: 1
   Done!