Skip to main content

A library for interacting with the cosmos networks

Project description

CosmPy

PyPI PyPI - Python Version PyPI - Wheel License

AEA framework sanity checks and tests flake8 mypy Black mypy

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cosmpy-0.3.1.tar.gz (353.9 kB view details)

Uploaded Source

Built Distribution

cosmpy-0.3.1-py3-none-any.whl (359.0 kB view details)

Uploaded Python 3

File details

Details for the file cosmpy-0.3.1.tar.gz.

File metadata

  • Download URL: cosmpy-0.3.1.tar.gz
  • Upload date:
  • Size: 353.9 kB
  • Tags: Source
  • Uploaded using 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.1 CPython/3.9.10

File hashes

Hashes for cosmpy-0.3.1.tar.gz
Algorithm Hash digest
SHA256 fa901d359174477f2dc7e0698aa2ff68c09e5f6edec987680ec501ac1dcc2332
MD5 51b4c5ac6691e52686c1718fa5065f5f
BLAKE2b-256 20151c12ae650ae546cb13ca2c27aa0e5cb26a60a6b6bd3cf6ab3f9500574cc0

See more details on using hashes here.

File details

Details for the file cosmpy-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: cosmpy-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 359.0 kB
  • Tags: Python 3
  • Uploaded using 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.1 CPython/3.9.10

File hashes

Hashes for cosmpy-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0c607bbbd2eaa10cdbbd504c062bd00769517c927a35283c9d446029e86d7129
MD5 8705b882ba234391da919814ad7a4899
BLAKE2b-256 9a461a4c49dfc961055e6e24083f702802a6a8b3f97de90a3096b4eb8cb122a7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page