/chainlibpy

Tools for Crypto.com wallet management and offline transaction signing

Primary LanguagePythonOtherNOASSERTION

Build Status codecov.io PyPI version Code style: black

chainlibpy

Version 1.0.0

Tools for Crypto.com wallet management and offline transaction signing

Installing

Installing from PyPI repository (https://pypi.org/project/chainlibpy):

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 transactions

from chainlibpy import Transaction, Wallet

wallet = Wallet.new()
tx = Transaction(
    wallet=wallet,
    account_num=11335,
    sequence=0,
    fee=1000,
    gas=70000,
    memo="",
    chain_id="test",
    sync_mode="sync",
)
tx.add_transfer(to_address="cro103l758ps7403sd9c0y8j6hrfw4xyl70j4mmwkf", amount=387000)
pushable_tx = tx.get_pushable()

One or more token transfers can be added to a transaction by calling the add_transfer method.

When the transaction is fully prepared, calling get_pushable will return a signed transaction in the form of a JSON string. This can be used as request body when calling the POST /txs endpoint of rpc.

thanks

thanks cosmospy for the following:

  • referenced the packages to sign transaction and create hd wallet
  • python lint config file
  • use same sign method