Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
136 lines (88 sloc) 5.46 KB

Blockchain CLI

The Helium blockchain CLI is an open-source Rust application that allows the user to create secure address key pairs and interact with the blockchain via the command line.

The source code is available via GitHub: https://github.com/helium/helium-wallet-rs

This guide will walk you through how to create various types of wallet, and perform some of the different blockchain specific functions.

{% hint style="danger" %} Please be sure to keep wallet files and passwords secure. There is no forgotten password and no recourse for lost files, keys and passwords! {% endhint %}

Installation

The Wallet application can either be downloaded from the GitHub releases page, or built from source. This guide will walk through building from source.

First, we'll assume you're using a Linux or macOS based system. To build from source you'll need the Rust programming language and its package manager, Cargo:

$ curl https://sh.rustup.rs -sSf | sh

Once Rust is installed, we'll need to check out the Wallet git repo and build it. You'll of course need Git installed first.

$ git clone https://github.com/helium/helium-wallet-rs.git
$ cd helium-wallet-rs
$ cargo build --release

Cargo will pull in all the required dependencies and build the application. Once complete you should have a binary available as ./target/release/helium-wallet

{% hint style="info" %} The latest master branch of the CLI is incompatible with the current production API while migration to the new API occurs.

Please use export HELIUM_API_URL=https://api.helium.wtf/v1 to point the CLI at the development server until migration is complete. {% endhint %}

Creating and Verifying Wallets

You can run ./target/release/helium-wallet -h or --help to get help at any time.

Creating a wallet from scratch

To create a simple wallet, run:

$ ./target/release/helium-wallet create basic

This will create a password protected wallet file located at wallet.key - if you want to output the wallet file to a different location you can specify -o mywalletfile.key when creating the wallet.

Creating a wallet using an existing 12 word seed phrase

If you've been using the Helium iOS/Android mobile application, you're likely to have an existing wallet and you've hopefully written the 12 word seed phrase down somewhere. To create a CLI wallet using that existing seed phrase you can do this:

$ ./target/release/helium-wallet create basic --seed

The CLI will then prompt you for your Seed Words: enter them in the correct order separated by spaces:

$ Seed Words: word1 word2 word3 ...

Creating a sharded wallet

Sharding wallet keys is supported via Shamir's Secret Sharing. A key can be broken into N shards such that recovering the original key needs K distinct shards. This can be done by passing options to create

$ ./target/release/helium-wallet create sharded -n 5 -k 3

This will create a wallet with 5 shards, with any 3 shards required. The files are stored as wallet.key.1 through wallet.key.5 - as before, the filename can be specified by passing the -o flag during the wallet creation.

Verifying and getting info on an existing wallet

If you have existing wallet files you can verify them by running:

$ ./target/release/helium-wallet verify 

If you just want to see the public address of the wallet:

$ ./target/release/helium-wallet info
+-----------------------------------------------------+---------+
| Address                                             | Sharded |
+-----------------------------------------------------+---------+
| 14d5tFhmy5wW98gS3NzDgqsLAAZ54QsMfMy5dNRdsGPw7a7USbC | false   |
+-----------------------------------------------------+---------+

You can pass -f mywallet.key to either the verify or info commands to use different wallet files.

Sending tokens

Once your wallet has been created it's easy to send HNT via the CLI:

$ ./target/release/helium-wallet pay <address> --hnt <amount>

You will be prompted for the password you used to create the wallet.

The value of --hnt can be down to 8 decimal places of precision. 0.00000001 is the smallest denomination that could be sent (also known as a bone).

If the --hash flag is passed to the command, the CLI will output the transaction hash which can then be checked against the Blockchain API pending transaction route to see the status of the transaction:

https://api.helium.io/v1/pending_transactions/<hash>

Or once the transaction has been confirmed:

https://api.helium.io/v1/transactions/<hash>

Checking balance

To check your wallet balance:

$ ./target/release/helium-wallet balance
+-----------------------------------------------------+------------+--------------+-----------------+
| Address                                             | Balance    | Data Credits | Security Tokens |
+-----------------------------------------------------+------------+--------------+-----------------+
| 14d5tFhmy5wW98gS3NzDgqsLAAZ54QsMfMy5dNRdsGPw7a7USbC | 0.00000000 | 0            | 0               |
+-----------------------------------------------------+------------+--------------+-----------------+
You can’t perform that action at this time.