MosPy
MosPy is a fork of the cosmospy library and aims to be a versatile transaction signing library for the whole cosmos ecosystem. It depends cosmospy-protobuf for the protos. Through this library you also can add your own transaction types and sign them through Mospy.
Documentation
A documentation with according examples can be found at https://mospy.ctrl-felix.de
Get Started
You can find a tutorial series on medium: https://medium.com/@ctrl-felix/mospy-tutorial-1-the-basics-95ec757047dc
Installation
Mospy is available through (pypi)[https://pypi.org/project/mospy-wallet]
python -m pip install mospy-wallet
Note: The package name in python is mospy even if it is called mospy-wallet on pypi as mospy already existed
Quickstart
More examples on: https://mospy.ctrl-felix.de/examples/
import httpx # optional
from mospy import Account, Transaction
account = Account(
seed_phrase="law grab theory better athlete submit awkward hawk state wedding wave monkey audit blame fury wood tag rent furnace exotic jeans drift destroy style",
address_index=12
)
tx = Transaction(
account=account,
gas=1000,
)
tx.set_fee(
amount=100,
denom="uatom"
)
# Add a transfer message to the transaction (multiple messages can be added)
tx.add_msg(
tx_type='transfer',
sender=account,
receipient="cosmos1tkv9rquxr88r7snrg42kxdj9gsnfxxg028kuh9",
amount=1000,
denom="uatom"
)
# Sign and encode transaction to submit it to the network manually
# REST endpoint (RPC or API)
tx_bytes = tx.get_tx_bytes_as_string()
# Submit the transaction through the Tendermint RPC
rpc_url = "https://rpc.cosmos.network/"
pushable_tx = json.dumps(
{
"jsonrpc": "2.0",
"id": 1,
"method": "broadcast_tx_sync", # Available methods: broadcast_tx_sync, broadcast_tx_async, broadcast_tx_commit
"params": {
"tx": tx_bytes
}
}
)
r = httpx.post(rpc_url, data=pushable_tx)
# Submit the transaction through the Cosmos REST API
rpc_api = "https://api.cosmos.network/cosmos/tx/v1beta1/txs"
pushable_tx = json.dumps(
{
"tx_bytes": tx_bytes,
"mode": "BROADCAST_MODE_SYNC" # Available modes: BROADCAST_MODE_SYNC, BROADCAST_MODE_ASYNC, BROADCAST_MODE_BLOCK
}
)
r = httpx.post(rpc_api, data=pushable_tx)
Different transaction types
Mospy is created to support every possible external transaction type. To make it easier some transaction types are built in and can be added directly to a transaction object. But it's not difficult to add your own transaction types! More about transaction types can be found in the docs.
Metadata
Release files for mospy-wallet 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mospy_wallet-0.6.0.tar.gz | 19.9 kB | Without provenance | Details for mospy_wallet-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mospy_wallet-0.6.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for mospy_wallet-0.6.0-py2.py3-none-any.whl |
Total release size: 37.5 kB
Release files / mospy_wallet-0.6.0.tar.gz
| Download URL | mospy_wallet-0.6.0.tar.gz |
|---|---|
| Size | 19.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aa85d0b185bc134161e5115d928492ce3e235a6751c9c2be0d8c7d347ce4e7d4
|
|
BLAKE2b-256 checksum How to use checksums |
ffd2c17c2a929eeaf9e8b09ae10393abf5d70edb6fe2c7419e07b5f78a6033ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.13
|
Release files / mospy_wallet-0.6.0-py2.py3-none-any.whl
| Download URL | mospy_wallet-0.6.0-py2.py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
52802646d61db9f3850fd0ca0508e751a99763896f15985d5be4d2f556b4e1f4
|
|
BLAKE2b-256 checksum How to use checksums |
53d6f8f873b6c801b67a69736bb74490c19cd08dcd817db629fb8357db787e78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.13
|
Security for mospy-wallet 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.