Skip to main content

A command-line interface for Hetu Chain interactions

Project description

Hetu Chain CLI

License: MIT Twitter


Causality Graph Future In Web3

SDKChainResearch


The Hetu CLI, hetucli, is a powerful command line tool for interacting with the Hetu blockchain. You can use it on any macOS, Linux, or WSL terminal to manage wallets, transfer HETU, query balances, interact with smart contracts, and more. Help information can be invoked for every command and option with --help.

Documentation

Installation steps are described below. For full documentation on how to use hetucli, see the Hetu CLI section on the developer documentation site.


Features

  • Wallet management (create, query balance, export private key)
  • HETU transfer, signing, send transaction
  • Query on-chain balance
  • Contract call (read-only)
  • Command line powered by Typer

Install on macOS and Linux

You can install hetucli on your local machine directly from source or PyPI. Make sure you verify your installation after you install:

Install from PyPI

Run

pip install -U hetu-pycli

Install from source

  1. Clone the Hetu CLI repo.
git clone https://github.com/hetu-project/hetu-pycli.git
  1. cd into hetu-pycli directory.
cd hetu-pycli
  1. Create and activate a virtual environment.
make init-venv
  1. Install dependencies and the CLI:

Using Poetry

pip install -U pip setuptools poetry
poetry install

Or, using Pip:

pip install .

Usage

You can invoke the CLI using the following command:

python -m hetu_pycli.cli --help

Or, if installed as a script:

hetucli --help

Wallet management

hetucli wallet create
hetucli wallet balance <address> --rpc <rpc_url>

Transfer

hetucli tx send --private-key <key> --to <address> --value <hetu> --rpc <rpc_url>

Configuration

Set the contract address

hetucli c set whetu_address <address>
hetucli c set staking_address <address>
hetucli c set subnet_address <address>
hetucli c set neuron_address <address>
hetucli c set amm_address <address>

Main Process(New,Staking,Swap)

New A Subnet

hetucli w import <private-key> --name test0
hetucli whetu deposit  --sender test0 --value  1000
hetucli whetu balance-of  test0
hetucli subnet get-network-lock-cost
hetucli whetu approve --spender <subnet_address>  --value 100 --sender test0 
hetucli subnet update-network-params --network-min-lock 100000000000000000000  --network-rate-limit 1 --lock-reduction-interval 10000  --sender <address>
hetucli subnet regist --sender test0 --name "AI Vision" --description "Computre vision and image processing network" --token-name "VISION" --token-symbol "VIS"

Staking and Participation

hetucli whetu approve --spender <stake_address>  --value 100 --sender test0
hetucli stake add-stake --sender test0 --amount 100
hetucli stake total-staked
hetucli stake allocate-to-subnet --netuid 1  --sender test0 --amount 50
hetucli neuron regist --sender test0 --netuid 1 --is-validator-role  --axon-endpoint "http://my-node.com" --axon-port 8080 --prometheus-endpoint "http://my-metrics.com" --prometheus-port 9090

Trading Subnet Tokens

hetucli subnet subnet-info --netuid 1 
hetucli c set amm_address <amm_pool_address>
hetucli amm pool-info
hetucli whetu approve --spender 0xa16E02E87b7454126E5E10d957A927A7F5B5d2be  --value 100 --sender test0
hetucli amm swap-hetu-for-alpha --hetu-amount-in  100 --alpha-amount-out-min 0   --sender test0 --to <to-address>

WHETU

hetucli whetu deposit --contract <address> --sender <address> --value <amount>
hetucli whetu withdraw --contract <address> --sender <address> --amount <amount>
hetucli whetu balance-of --contract <address> --account <address>
hetucli whetu transfer --contract <address> --to <address> --value <amount> --sender <address>
hetucli whetu approve --contract <address> --spender <address> --value <amount> --sender <address>
hetucli whetu total-eth --contract <address>
hetucli whetu total-supply --contract <address>
hetucli whetu nonces --contract <address> --owner <address>

Staking, Subnet, Swap

hetucli stake total-staked --contract <address>
hetucli stake add-stake --contract <address> --sender <address> --amount <amount>
hetucli subnet next-netuid --contract <address>
hetucli subnet register-network --contract <address> --sender <address> --name ... --description ... --token-name ... --token-symbol ...
hetucli amm alpha-price --contract <address>
hetucli amm swap-hetu-for-alpha --contract <address> --sender <address> --hetu-amount-in <amount> --alpha-amount-out-min <amount> --to <address>

Contract call

hetucli contract call --address <contract_addr> --abi-path <abi.json> --function <fn> --args "1,2,3" --rpc <rpc_url>

Running Tests & Development

To run the tests, ensure you have the Hetu CLI installed and configured. Then, execute:

poetry run pytest tests

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hetu_pycli-0.1.0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hetu_pycli-0.1.0-py3-none-any.whl (34.2 kB view details)

Uploaded Python 3

File details

Details for the file hetu_pycli-0.1.0.tar.gz.

File metadata

  • Download URL: hetu_pycli-0.1.0.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.18

File hashes

Hashes for hetu_pycli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a3e1d7b71bfcedc05291158ac486ade524bcf9f675acac3f8e1ba477da20d921
MD5 59d0c604594073e0c387c66067e4ba2c
BLAKE2b-256 80cf844484c567ae301ce2a31d840deb4eae9b951aad5b4faae79c1a11330a6b

See more details on using hashes here.

File details

Details for the file hetu_pycli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hetu_pycli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 34.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.18

File hashes

Hashes for hetu_pycli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d24ef78b8458e4a576d40c678485c06624cd77c035f5004760b9ad799a4af891
MD5 ee9f7a6f92fe861f1ebb9e9dcca8e799
BLAKE2b-256 621dcbddd944150fb503e01cbb02056cd8b63dd1236eb07af7de77b9c53d1fdc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page