chainlibpy
Tools for Crypto.org Chain wallet management and offline transaction signing
Installing
Require Python >= 3.8, installing from PyPI repository:
pip install chainlibpy
Usage
Generating a wallet
from chainlibpy import Wallet
# create a wallet
wallet = Wallet.new()
# or you can recover from an mnomic
# mnemonic = "dune car envelope chuckle elbow slight proud fury remove candy uphold puzzle call select sibling sport gadget please want vault glance verb damage gown"
# wallet = Wallet(mnemonic)
print(wallet.private_key)
print(wallet.public_key)
print(wallet.address)
Signing and broadcasting a transaction
Please refer to example/transaction.py for how to start a local testnet with pystarport and change information below to run the examples successfully.
# Obtained from {directory_started_pystarport}/data/chainmaind/accounts.json
# To recover one of the genesis account
- MNEMONIC_PHRASE = "first ... last"
+ MNEMONIC_PHRASE = "REMEMBER TO CHANGE"
# Obtained from {directory_started_pystarport}/data/chainmaind/accounts.json
- TO_ADDRESS = "cro...add"
+ TO_ADDRESS = "REMEMBER TO CHANGE"
Interact with mainnet or testnet
Please refer to example/secure_channel_example.py on how to use secure gRPC channel with server certificate to interact with mainnet or testnet.
Acknowledgement
Thanks to cosmospy for the following:
- referenced the packages to sign transaction and create hd wallet
- python lint config file
- use same sign method
Thanks to eth-utils for the following:
- Conversion of different units without facing precision issues in Python
Development
Set up development environment
Run command below to install dependencies (more about poetry):
poetry install
Add pre-commit git hook
To set up the git hook scripts, so that pre-commit will run automatically on git commit:
pre-commit install
Generate gRPC code
poetry shell
./generated_protos.sh
NOTE: By default, master branch of cosmos-sdk is used. Use command below to download a different version:
./generated_protos.sh -COSMOS_REF=v0.44.5
If more generated gRPC code is needed in the future, please add the path to .proto file needed here in generated_protos.sh:
# Add .proto files here to generate respective gRPC code
PROTO_FILES="
$COSMOS_SDK_DIR/proto/cosmos/auth/v1beta1/auth.proto
+$COSMOS_SDK_DIR/proto/other.proto
...
Tox
Tox is a tool to automate and standardize testing processes in Python.
For this project, the list of environment that will be run when invoking tox command is py{38,39}. Hence we need to set up Python 3.8 and 3.9 for this project. Run command below to set a local application-specific Python version (in this case 3.8 and 3.9) with pyenv:
pyenv local 3.8.a 3.9.b
Note: a and b are python versions installed on your computer by pyenv.
After running command above, a .python-version file will be generated, which means python versions inside .python-version are presented for this project. Now, running command tox should succeed without prompting environment missing error.
Run command below to verify:
poetry run tox
# or
poetry shell
tox
It is also recommended to run tox command before pushing a commit.
Metadata
Release files for chainlibpy 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| chainlibpy-3.0.0-cp38-cp38-manylinux_2_31_x86_64.whl | CPython 3.8 | CPython 3.8 | Linux glibc 2.31+ x86-64 | Details |
Release files / chainlibpy-3.0.0-cp38-cp38-manylinux_2_31_x86_64.whl
| Download URL | chainlibpy-3.0.0-cp38-cp38-manylinux_2_31_x86_64.whl |
|---|---|
| Size | 38.9 kB |
| Tags | CPython 3.8 Linux glibc 2.31+ x86-64 |
|
SHA-256 checksum How to use checksums |
eb216ae92ec83a1e130b2006818ddade7474ca59a543c8017feedc2581f68981
|
|
BLAKE2b-256 checksum How to use checksums |
4dc962cee1c68bd2b81efe158a4096e686531561e001519fad7c63a23cc2abbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.10
|
Security for chainlibpy 3.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.