A Python SDK for interacting with the hetu blockchain (cosmos-sdk + EVM), wrapping EVM contract and cosmos RPC client features.
Project description
hetu-pysdk
A Python SDK for interacting with the hetu blockchain (Cosmos SDK + EVM), wrapping EVM contract and Cosmos RPC client features. Provides Axon/Dendrite/Synapse communication, EVM JSON-RPC, and ETH-compatible signing/verification.
Features
- EVM contract interaction via web3.py
- Cosmos RPC client support
- Axon (server) and Dendrite (client) neuron communication
- Synapse: extensible message/data structure for requests
- ETH/EVM-compatible signing and signature verification
- Full support for ETH wallet/address
- Mock/test infrastructure for all core modules
- Custom exceptions and error handling
- Modern, extensible, and type-annotated codebase
Project Structure
hetu/— Core SDK modules (axon, dendrite, synapse, chain_api, etc.)chain_api/— EVM/Cosmos chain RPC and wallet logicchain_data/— Data structures for chain state, neurons, axons, etc.utils/— Utilities, logging, networking, versioning, mockstests/— Pytest test cases for all major featurescontrib/— Contributing guidelines, changelog, etc.README.md— Project overview and installation instructions
Installation
Install from PyPI
Run
pip install -U hetu-pysdk
Install from source
- Clone the Hetu SDK repo.
git clone https://github.com/hetu-project/hetu-pysdk.git
cdintohetu-pysdkdirectory.
cd hetu-pysdk
- Create and activate a virtual environment.
make init-venv
- Install dependencies and the CLI:
To install the SDK, you can use Poetry, which manages dependencies and virtual environments. Make sure you have Poetry installed, then run:
pip install -U pip setuptools poetry wheel
poetry install
Usage
Basic EVM/Cosmos Client
from hetu_pysdk import HetuClient
client = HetuClient(rpc_url="http://localhost:26657", evm_rpc_url="http://localhost:8545")
block_number = client.eth_blockNumber()
balance = client.eth_getBalance(address, "latest")
Axon/Dendrite/Synapse Example
import hetu_pysdk as ht
class EchoSynapse(ht.Synapse):
input: str
output: str = None
def echo_forward(syn: EchoSynapse) -> EchoSynapse:
syn.output = syn.input
return syn
def verify_echo(syn: EchoSynapse):
assert isinstance(syn.input, str)
# Create ETH wallet/account
dendrite_wallet = ht.Account.create()
axon_wallet = ht.Account.create()
# Start Axon server
axon = ht.Axon(account=axon_wallet, port=8091)
axon.attach(forward_fn=echo_forward, verify_fn=verify_echo)
axon.serve(netuid=1).start()
# Dendrite client sends request
syn = EchoSynapse(input="hello")
dendrite = ht.Dendrite(account=dendrite_wallet)
response = dendrite.call(ht.AxonInfo(ip="127.0.0.1", port=8091, hotkey=axon_wallet.address), syn)
print(response.output) # 'hello'
ETH-Compatible Signing & Verification
- All requests are signed using eth_account and encode_defunct (EIP-191).
- Axon verifies signatures using Account.recover_message, matching claimed address.
- Nonce and computed_body_hash included in signature to prevent replay/tampering.
Testing
poetry run pytest
- All core modules and communication patterns are covered by tests in
tests/. - Includes Axon/Dendrite/Synapse integration, EVM RPC, and mock logic.
Mock/Offline Support
- Mock classes and MagicMock are used for offline/test scenarios.
- See
hetu/utils/mock/hetutensor_mock.pyfor mock neuron/chain data.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hetu_pysdk-0.1.0.tar.gz.
File metadata
- Download URL: hetu_pysdk-0.1.0.tar.gz
- Upload date:
- Size: 149.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e208cd93a363120a4c5da2dda13f71d19601d24926d708172c8b77211d61eea
|
|
| MD5 |
2a49edb50fbec964641db9c5abd1895f
|
|
| BLAKE2b-256 |
acb2acd2b97a1aaa0cc61d0795069f10125ed4e9fd32e30373251794135d10a7
|
File details
Details for the file hetu_pysdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hetu_pysdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 174.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eedca7a6c72dfe14f78b4f39fda603d6b0e6f9f33651e0483480adb7fa0cd9bb
|
|
| MD5 |
f4432743c2d62e773a9849d3a73d0c0d
|
|
| BLAKE2b-256 |
a8b57c059bbfcaf42817d22fe6b977da53efc5c0b4f7249f2ac3971e2311a574
|