Skip to content
Python tools for Cosmos wallet management and offline transaction signing
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cosmospy Bump version: 1.0.0 → 2.0.0 Jun 13, 2019
tests
.bumpversion.cfg Bump version: 1.0.0 → 2.0.0 Jun 13, 2019
.coveragerc Code for transaction signing and address generation Jun 8, 2019
.gitignore Code for transaction signing and address generation Jun 8, 2019
.pre-commit-config.yaml
.travis.yml
CHANGELOG.md
LICENSE Initial commit Jun 6, 2019
README.md Bump version: 1.0.0 → 2.0.0 Jun 13, 2019
push_to_pypi.sh Add bash script for pushing to pypi Jun 8, 2019
pyproject.toml
requirements.txt Rename UnsignedTransaction as Transaction. Some config changes Jun 13, 2019
setup.cfg
setup.py Bump version: 1.0.0 → 2.0.0 Jun 13, 2019

README.md

Build Status codecov.io PyPI version Code style: black

cosmospy

Version 2.0.0

Tools for Cosmos wallet management and offline transaction signing

Requirements

apt-get install libsecp256k1-dev

Installing

Installing from PyPI repository (https://pypi.org/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-2",
    sync_mode="sync",
)
tx.add_atom_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.

You can’t perform that action at this time.