CosmPy
A python library for interacting with cosmos based blockchain networks
Installing
To install the project use:
pip3 install cosmpy
Getting started
Below is a simple example for querying an account's balance and sending funds from one account to another using RestClient:
from cosmpy.clients.ledger import CosmosLedger
from cosmpy.clients.crypto import CosmosCrypto, Coin
# Data
rest_node_address = "http://the_rest_endpoint"
alice_crypto = CosmosCrypto(private_key_str="<private_key_in_hex_format>"))
chain_id = "some_chain_id"
denom = "some_denomination"
bob_address = "some_address"
ledger = CosmosLedger(chain_id=chain_id, rest_node_address=rest_endpoint_addres)
# Query Alice's Balance
res = ledger.get_balance(alice_crypto.get_address(), denom)
print(f"Alice's Balance: {res} {denom}")
# Send 1 <denom> from Alice to Bob
ledger.send_tokens(alice_crypto, bob_address, [Coin(amount="1", denom=denom)])
Documentation
To see the documentation, first run:
make generate-docs
Then (if on Linux or MacOS):
make open-docs
And if on windows, open docs/build/html/index.html.
Examples
Under the examples directory, you can find examples of basic ledger interactions with cosmpy using both REST and gRPC, e.g. querying, sending a transaction, interacting with a smart contract, and performing atomic swaps. To run any example <example_file_name>:
python ./examples/<example_file_name>.py
Extra Resources
Metadata
Release files for cosmpy 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cosmpy-0.3.0.tar.gz | 354.3 kB | Without provenance | Details for cosmpy-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cosmpy-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for cosmpy-0.3.0-py3-none-any.whl |
Total release size: 713.3 kB
Release files / cosmpy-0.3.0.tar.gz
| Download URL | cosmpy-0.3.0.tar.gz |
|---|---|
| Size | 354.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5fc06139216d9eee602e489058b2f4c4919090995e7842331a66237108fa4d3a
|
|
BLAKE2b-256 checksum How to use checksums |
fab4ad2945695c35fffb8770ec18c594221c6c1b5f4917049cb4a027f3ebcf9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9
|
Release files / cosmpy-0.3.0-py3-none-any.whl
| Download URL | cosmpy-0.3.0-py3-none-any.whl |
|---|---|
| Size | 359.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8102536ee2b07fbd0e267bb0bd145f41c5a6faaddd0d92c31ebdd3bbd451d371
|
|
BLAKE2b-256 checksum How to use checksums |
fafa7e634335f8066494262f397f777dddb206941687d14ca55f9a4e638e6ecc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9
|
Security for cosmpy 0.3.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.