Package: hydra-chain-py
Hydra Chain Integration & Tools LibraryThis is a Python support library for the Hydra Chain project (https://hydrachain.org) aimed at simplifying the process of using and developing apps for the blockchain.Primarily,hypy(pronounced "hippie") currently provides:RPC tools to access the Hydra JSON-RPC service.A flexible command line tool with simple integration.Application infrastructure to extend apps & tools.Integrated apps for common tasks such as monitoring or connecting to new nodes.Quick StartIf you know what this is and just want to get going, install:pip install hydra-chain-pyOr with poetry:poetry add hydra-chain-pyThis adds thehydrapackage to your Python installation.Then, to get started, run:hy --helpFull download/install and usage instructions follow.UsageThis library connects to a Hydra node on a local system or over a network.The primary tool to interface with the node is calledhycli, and for the most part behaves exactly the same ashydra-cli,
with some nicer output options:hycli getinfogetinfo.version180506.protocolversion70017.walletversion169900.balance28047.31917165.stake1452.99760027.locked.used128.free65408.total65536.locked65536.chunks_used2.chunks_free2.blocks155763.timeoffset0.connections8.proxy.difficulty.proof-of-work1.52587890625e-05.proof-of-stake797825.1819042678.testnetTrue.moneysupply20931869.76468454.burnedcoins73748.17511400.keypoololdest1635530802.keypoolsize2000.unlocked_until1741407462.relayfee0.004.errorsThere's alsohytop, which periodically displays useful node status info in a human-readable format:hytop -Cnow2022-01-0516:21:36.930567-08:00
utcnow2022-01-0600:21:36.930584
connectioncount8apr107.2079665372164

stakinginfo.enabledTrue.stakingTrue.difficulty797825.1819042678.search-interval1:51:28.weight28047.31917165.netstakeweight3918664.173517.expectedtime4:58:03

walletinfo.walletname''.balance28047.31917165.stake1452.99760027.txcount2769.unlocked_until2025-03-0720:17:42Andpeerscan, which attempts to connect to new nodes:peerscan -vvINFO:hypy:serverreports327connections
INFO:hypy:loaded327peers
INFO:hypy:loaded1201nodes
INFO:hypy:trying883potentialnewpeers
INFO:hypy:servernowreports329connectionsClone & InstallThis is both a library that you can import into your Python code and a command line tool that you can use and extend.When installinghypy, the command line tools become available as well.To install the latest from git without cloning the repository,  jump down to theRemote Installationsection.Clone/Download Sources:git clone https://github.com/hydraverse/hypyCloninginto'hypy'...
...EnvironmentThe simplest way to usehypyis to install it at the system level, but sometimes it can be hard to manage varying Python
version needs and dependencies.If installing at the system level, jump down to theInstallationsection.PoetryThis is now the only recommended/supported way to install or develop with this package.Create a new poetry project:poetry new myproject && cd myproject && poetry add hydra-chain-pyInstallingFrom SourceInstalling from the clonedhypylibrary folder:poetry install .Remote InstallationInstalling directly from GitHub:poetry add git+https://github.com/hydraverse/hypyOr to get a specific branch, tag, or revision:poetry add git+https://github.com/hydraverse/hypy@v2.7.2This example installs thev2.7.2tagged version.Uninstallpip uninstall hypyOrpoetry remove hydra-chain-pyPackagingYou can create a redistributable wheel package for later installation with the following command:poetry buildUse:hyhyis theHydra Chain Tool, a command-line toolkit meant to run standalone modules, akaapps, with convenient access to instantiated library objects.Some apps are provided by the library, and thehymodule provides you with a means to
integrate your own apps and run them as if they were part of the tool. More on that in the example app below.Running an app on the command line looks something like this(note: '֍' is the command shell prompt):hy [-h] <some-app> [-h] [options] [app params]Use the-hoptionbeforethe app name to see a list of apps, and after to get usage for a particular app.The primary apps currently available arecliandtest. These are provided as system-level
commands alongsidehywhen you installhypy.This means that instead of callinghy cli ..., for example, you can usehycli ...instead.Note that all program options (except-hor-v) must appearafterthe app name.Run Unit Testshy test - [-k "<test_name_pattern> or <test_name_pattern> ..."]This command is also available globally (with slight variation, no need for-param) after installation ashytest.You can also specify different parameters for the tests with environment variables, such asHYPY_LOG.
These variables also work withhy.HY_RPC_WALLET=watch HY_LOG=ERROR hy test -===========================testsessionstarts============================platformlinux--Python3.8.10,pytest-6.2.5,py-1.11.0,pluggy-1.0.0
rootdir:/home/halo/pr/hy/hypy
collected13itemshydra/test/app/cli.py::HydraCLIAppTest::test_app_cli_runnablePASSED[7%]hydra/test/rpc.py::HydraRPCTest::test_rpc_stubPASSED[15%]hydra/app/txvio.py::TxVIOAppTest::test_0_txvio_runnablePASSED[23%]hydra/app/txvio.py::TxVIOAppTest::test_1_txvio_runPASSED[30%]hydra/app/ascan.py::AScanAppTest::test_0_ascan_runnablePASSED[38%]hydra/app/ascan.py::AScanAppTest::test_1_ascan_runPASSED[46%]hydra/app/atrace.py::ATraceAppTest::test_0_atrace_runnablePASSED[53%]hydra/app/atrace.py::ATraceAppTest::test_1_atrace_runPASSED[61%]hydra/app/lstx.py::TxListAppTest::test_0_lstx_runnablePASSED[69%]hydra/app/lstx.py::TxListAppTest::test_1_lstx_runPASSED[76%]hydra/app/peerscan.py::PeerScanTest::test_0_peerscan_runnablePASSED[84%]hydra/app/peerscan.py::PeerScanTest::test_1_peerscan_runPASSED[92%]hydra/app/top.py::TopAppTest::test_0_top_runnablePASSED[100%]===========================13passedin37.17s============================Standalone TestingWhen developing ouside the library, tests can be run for standalone Application implementations.hy-test examples/my_hydra_app.pyFull Usage:hyNOTE:Tab-completion is available viaargcompletebut per-app parameters
won't be shown, only the primaryhyparameters.hyhy -husage:hy[-h][-v][-lLOG][--rpcRPC][--rpc-walletRPC_WALLET][--rpc-testnet][-J][-j][-f]{cli,test,ascan,atrace,lstx,txvio,peerscan,top}...

HyPyLibraryApplicationTool.

positionalarguments:{cli,test,ascan,atrace,lstx,txvio,peerscan,top}applicationtorun.ARGSapplicationargs.

optionalarguments:-h,--helpshowthishelpmessageandexit-v,--verboseverboselevel(upto3x)(env:HYPY_V).-lLOG,--logLOGloglevel(name:error,warning,info,debug,notset)(env:HYPY_LOG).--rpcRPCrpcurl(env:HY_RPC)--rpc-walletRPC_WALLETrpcwalletnameoverride(env:HY_RPC_WALLET)--rpc-testnetrpctestnetoverride(env:HY_RPC_WALLET)-J,--json-prettyoutputparseablejson-j,--jsonoutputparseablejson-f,--fulloutputfullnames(non-jsononly)clihycli -husage:hycli...[-f]...

optionalarguments:...

cli:rpccliinterface-f,--fulloutputfullnames(non-jsononly)CALLrpcfunctiontocallPARAMrpcfunctionparametersOnly the last section in an app's help message (cliin the above case) will differ
between apps.