Skip to main content

Transaction Generator Python library

This is for python 3.6+ only

A transaction generator library for the Harmony Blockchain. It utilizes the CLI to generate transactions.

Documentation can be found here and example scripts that use the transaction generator can be found in the root of this directory with the suffix _example.py

Note that this only works on MacOS or Linux. It could possibly work on WSL, but this is untested.

Install

You can install the library from pypi using the following command:

python3 -m pip install harmony-transaction-generator

You will require the latest version of pyhmy (which may not install if you already have it). You can get the latest with the following command:

python3 -m pip install pyhmy --upgrade

Development Installation

Clone this repo and run:

make install

Examples

Example script when running for devnet can be seen here

You can run localnet_example.py if you have a localnet running. To start a localnet, reference the main harmony repo to set up your ev environment, then run test/debug.sh in the main repo.

The localnet is an easy way to develop your scripts without relying or using real network currency.

Important note about funding keys

One must have keys in the keystore that have funds on ALL shards (if one wishes to funds accounts on all shards). Note that one account does NOT have to have funds on all shard, but across all accounts in the keystore, there should be funds on all shards

This is because the library only does same shard transfers when funding to be conservative.

How it works

The docs can be found here.

Take a look at the localnet_example.py for some idea of how it works. Essentially, it follows a source / sink model for transaction generation (explained more in the start function here). Moreover, the annotations of the config in localnet_example.py should give a better idea of how to use the library.

A video demoing library can be seen here

Analysis

The analysis module of this library has a verify_transaction function that looks at the transaction logs and checks if said transactions appear on the blockchain. Refer to here for mode details on how it works.

The library logs everything it can, so one can read the log files to analyze it. The filepath/filename can be accessed with the filename attribute of the logger, for example tx_gen.Loggers.transaction.filename.

Note that all times in the logs are in UTC.

Caveat

The package has NOT been thoroughly tested so please report bugs and/or PR fixes if you find any, thank you!

Troubleshooting Errors While Testing

Possible fixes

  • Backup and clear keystore at ~/.hmy_cli/account-keys
  • Update pyhmy to latest version, can be checked here.

Check version with python3 -m pip list | grep pyhmy

  • If current balance is not enough for requested transfer, try increasing the 'INIT_SRC_ACC_BAL_PER_SHARD' value in the config file

Metadata

Release files for harmony-transaction-generator 20.1.48

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for harmony-transaction-generator 20.1.48
File Size Uploaded
harmony_transaction_generator-20.1.48.tar.gz 16.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for harmony-transaction-generator 20.1.48
File Interpreter ABI Platform
harmony_transaction_generator-20.1.48-py3-none-any.whl Python 3 none any Details

Total release size: 34.9 kB

Release files / harmony_transaction_generator-20.1.48.tar.gz

Download URL harmony_transaction_generator-20.1.48.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ab06b2521748b5b2d681d966b3c82e911dc0fb5a37ea81fd8a7f583510a9d923
BLAKE2b-256 checksum
How to use checksums
da379e48f0e944f555fb3328d465a84df9e2904e6dcece62e9722372fa273f5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

Release files / harmony_transaction_generator-20.1.48-py3-none-any.whl

Download URL harmony_transaction_generator-20.1.48-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cdf90322b75bb094e3a0da3501115d482f0e958c4d7b62fe623b57365e8504e5
BLAKE2b-256 checksum
How to use checksums
d419d1a5c8ad5919728a73304b3175bdcea8e848e04c0545ce20afdf314299a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page