Skip to content

Instantly share code, notes, and snippets.

@Daniel-VDM
Last active March 23, 2021 20:57
Show Gist options
  • Save Daniel-VDM/5bcd3fc09d63f5712dfe75095da321b6 to your computer and use it in GitHub Desktop.
Save Daniel-VDM/5bcd3fc09d63f5712dfe75095da321b6 to your computer and use it in GitHub Desktop.

Send transactions using the Harmony CLI from a CSV file

Install

  1. (Optional) Open terminal and cd to wherever you want to install your CLI. Personally I like ~/bin.
mkdir -p ~/bin && cd ~/bin
  1. Get the latest Harmony CLI version
curl -O https://raw.githubusercontent.com/harmony-one/go-sdk/master/scripts/hmy.sh && chmod +x ./hmy.sh && ./hmy.sh -d
  1. Install the CSV parser script in the same directory
curl -O https://raw.githubusercontent.com/harmony-one/go-sdk/master/scripts/hmy-csv.py && chmod +x ./hmy-csv.py

Note that this will require python 3.6 or newer. You can check this with the following command python3 --version.

  1. Create your CSV file (with numbers, excel, sheets, etc..), make sure to follow this template.

Note that the follow column names must exist: from, to, amount, from-shard, to-shard, passphrase-file (optional), passphrase-string (optional), gas-price (optional).

  1. Save/download the CSV file to your computer. If you are using MacOs and google sheets, your csv file will probably be in ~/Downloads. Note this for later.

Using the Script

MAKE SURE ALL from KEYS ARE IN THE CLI'S KEYSTORE. IMPORT KEYS FIRST IF NEEDED.

Reference docs here on how to import keystores into the CLI.

Basic (slow but safe)

  1. Go do where you installed your CLI. If using my example in the install section, do cd ~/bin.
  2. Run the script with the following command (for mainnet):
./hmy-csv.py ~/Downloads/some-file.csv --node https://api.s0.t.hmny.io/

Substitute ~/Downloads/some-file.csv with the path to your CSV file on your computer.

You can also substitute https://api.s0.t.hmny.io/ for whatever endpoint you want.

  1. Respond to the prompts and make sure to check the parsed transactions before sending it!

Fast (does not check if a transaction has confirmed)

  1. Go do where you installed your CLI. If using my example in the install section, do cd ~/bin.
  2. Run the script with the following command (for mainnet):
./hmy-csv.py ~/Downloads/some-file.csv --fast --node https://api.s0.t.hmny.io/

Substitute ~/Downloads/some-file.csv with the path to your CSV file on your computer.

You can also substitute https://api.s0.t.hmny.io/ for whatever endpoint you want.

  1. Respond to the prompts and make sure to check the parsed transactions before sending it!

Automation (for scripting on testnets)

  1. Note where you saved the hmy-csv.py file. For me its:
~/go/src/github.com/harmony-one/go-sdk/scripts/hmy-csv.py
  1. Run the script with the following command:
~/go/src/github.com/harmony-one/go-sdk/scripts/hmy-csv.py ~/Downloads/some-file.csv --use-default-passphrase --yes --fast --batch-size 25 --chain-id testnet -n http://3.231.157.246:9500/

Note that this just about shows every option one could need when using this script. Normally not all fields are needed.

Help

You can view all of the possible options and what they do with:

./hmy-csv.py --help
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment