Skip to main content

Tools for Cosmos wallet management and offline transaction signing

Project description

Build Status codecov.io PyPI version Code style: black

cosmospy

Version 3.0.2

Tools for Cosmos wallet management and offline transaction signing

Installing

Installing from PyPI repository (https://pypi-hypernode.com/project/cosmospy):

pip install cosmospy

Usage

Generating a wallet

from cosmospy.addresses import generate_wallet
wallet = generate_wallet()

The value assigned to wallet will be a dictionary just like:

{
    'private_key': '6dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515afa',
    'public_key': '03e8005aad74da5a053602f86e3151d4f3214937863a11299c960c28d3609c4775',
    'address': 'cosmos1jkc7hv9j92gj7r6sqq0l630lv4kqyac7t2dj2t'
}

Signing transactions

from cosmospy.transactions import Transaction
tx = Transaction(
    privkey="26d167d549a4b2b66f766b0d3f2bdbe1cd92708818c338ff453abde316a2bd59",
    account_num=11335,
    sequence=0,
    fee=1000,
    gas=37000,
    memo="",
    chain_id="cosmoshub-3",
    sync_mode="sync",
)
tx.add_transfer(recipient="cosmos103l758ps7403sd9c0y8j6hrfw4xyl70j4mmwkf", amount=387000)
pushable_tx = tx.get_pushable_tx()

The value assigned to pushable_tx will be a signed transaction in the form of a JSON string. The string can be used as request body when calling the POST /txs endpoint of the Cosmos REST API.

Contributing

  1. Fork/clone the repository.

  2. Install dependencies (you'll probably want to create a virtual environment, using your preferred method, first).

    pip install -r requirements.txt
    
  3. Install pre-commit hooks

    pre-commit install
    
  4. After making changes and having written tests, make sure tests pass:

    pytest
    
  5. Commit, push, and make a PR.

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

cosmospy-3.0.2.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file cosmospy-3.0.2.tar.gz.

File metadata

  • Download URL: cosmospy-3.0.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.5

File hashes

Hashes for cosmospy-3.0.2.tar.gz
Algorithm Hash digest
SHA256 a140c9b8f3af24de28e271d98fa67d866a192f2397036a1054f37ab0d3b34873
MD5 91329d1a06b62f564605db0fcabc0077
BLAKE2b-256 148e370d4b095bf032a22d95910ec83f0c7c9feeb519193e3959eb6d4899a6c8

See more details on using hashes here.

Provenance

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