Hedera SDK in Python
Project description
hedera-sdk-py
Hedera SDK in Python
This is basically a python wrapper of Hedera SDK in Java.
Install
pip install hedera-sdk-py this will work later, for now:
pip install https://github.com/wensheng/hedera-sdk-py/releases/download/v2.0.5-beta.9/hedera_sdk_py-2.0.5b9-py3-none-any.whl
How to Use
from hedera import PrivateKey
prikey = PrivateKey.generate()
print("Private key: {}".format(prikey.toString()))
print("Public key: {}".format(prikey.getPublicKey().toString()))
You must make sure JAVA_HOME is set to a JRE/JDK that's >=11. Do a echo $JAVA_HOME
on Linux/MacOS or echo %JAVA_HOME%
on Windows to confirm.
On Windows, if you get "no jvm dll found" error, you need to add %JAVA_HOME%/bin/server (i.e. C:\Program Files\Java\jdk-11.0.10\bin\server) to your path.
See examples for more example usages.
For most examples, you need to set OPERATOR_ID
AND OPERATOR_KEY
environment variables.
How to Build
(Ignore this section unless you want to contribute or make custom SDK)
Hedera-sdk-py requires JDK >=11, either OpenJDK or Oracle JDK.
Clone this repo:
git clone --recurse-submodules https://github.com/wensheng/hedera-sdk-py.git
Patch Java code:
patch -p 1 -d hedera-sdk-java < patches/961b6dc9.patch
To insure patching success, check out the commit whose hash match the patch filename. For example:
cd hedera-sdk-java
git checkout 961b6dc9
cd ..
patch -p 1 -d hedera-sdk-java < patches/961b6dc9.patch
As of now (2021/4), the difference is very minimal, almost no java source code is changed, only build.gradle's are modified to ensure jar packaging. But in the future, java source code might be modified to provide convience for interacting with SDK in Python.
You can revert the patches:
cd hedera-sdk-java
git reset --hard
Build the Jar (make sure JAVA_HOME set to a JDK that's >=11):
cd hedera-sdk-java
./gradlew uberJar
Generate code:
python scripts/generate_code.py
Build package:
rm -fr build dist
python -m build
Test package (preferably inside a virtual env or pipenv):
pip uninstall hedera-sdk-py
pip install dist/hedera_sdk_py-(current_version)-py3-none-any.whl
Upload to Pypi (don't do this unless you're me):
python -m twine upload dist/*
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
Hashes for hedera_sdk_py-2.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f13e7372c984e63d6985c5f09f9565c9b0bfd1541c7711fd02004f1dd84a123 |
|
MD5 | 9f1cd697f625fad5d5eaa859f914058f |
|
BLAKE2b-256 | 745bc3e45823f10cbd82dc3d1b5b09fd76e2d4fac109d3657e804bfa76df094f |