Tools for Crypto.org Chain wallet management and offline transaction signing
Project description
chainlibpy
Version 2.0.0
Tools for Crypto.org Chain wallet management and offline transaction signing
Installing
Require Python >= 3.7, 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
from chainlibpy.amino import StdFee, Coin
from chainlibpy.amino.message import MsgSend
wallet = Wallet.new()
fee = StdFee("300000", [Coin("100000")])
tx = Transaction(
wallet=wallet,
account_num=11335,
sequence=0,
fee=fee,
memo="",
chain_id="test",
sync_mode="sync",
)
from_add = wallet.address
msg = MsgSend(
from_address=wallet.address,
to_address="cro103l758ps7403sd9c0y8j6hrfw4xyl70j4mmwkf",
amount="387000",
)
tx.add_msg(msg)
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
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
chainlibpy-2.0.0.tar.gz
(14.4 kB
view hashes)