cardanomsg
Store and retrieve text or JSON in the Cardano blockchain metadata.
Installation
You can install the module using pip:
pip install cardanomsg
Usage
A BlockFrost API account is required (to prevent needing to run the blockchain locally on your PC).
Send message
Send a message in a transaction.
from cardanomsg.transaction import send_message
transaction_hash = send_message("<BLOCKFROST_PROJECT_ID>", "wallet.skey", "<RECIPIENT_ADDRESS>", 1000000, "Hello World")
Send message with label
Send a message with a searchable label in a transaction.
label = uuid.uuid4().int & (1<<32)-1
payload = {
"id": 12345,
"text": "Hello World"
}
transaction_hash = send_message("<BLOCKFROST_PROJECT_ID>", "wallet.skey", "<RECIPIENT_ADDRESS>", 1000000, payload, label)
The label must be numeric. Wait 1-3 minutes after submitting the transaction to find your label.
Get message
Get a message from a transaction.
from cardanomsg.transaction import get_message
message = get_message("<BLOCKFROST_PROJECT_ID>", "079112f6a5192c6eeae57de0607d61e07dea864efc2bbad7aa953795a5c56aae")[0].json_metadata
You can also view the message on the blockchain using Cardanoscan.
Summary | UTXOs | Metadata (1)
Metadata Hash: 2f86fa9fdfcb606ab2b5f060bd125848e45187cf2c798ab389e6a9af98ba8ad1
Public Label: 1
Value: "Hello World"
Find message
Find messages using a label.
from cardanomsg.transaction import find_message
messages = find_message(<BLOCKFROST_PROJECT_ID>, 1782959986)
for message in messages:
print(message.json_metadata)
Find messages using a label on Cardano mainnet, count 10, page 2, sorted by most recent.
from blockfrost import ApiUrls
messages = find_message(<BLOCKFROST_PROJECT_ID>, 123, api=ApiUrls.mainnet, count=10, page=2, order='desc')
The label must be numeric.
Create wallet
Create a wallet.
from cardanomsg.wallet import create
result = create()
Two files will be created: wallet.skey and wallet.addr.
The contents of wallet.skey is the secret key with the following format.
{
"type": "PaymentSigningKeyShelley_ed25519",
"description": "Payment Signing Key",
"cborHex": "<SENDER_SECRET_KEY>"
}
Publishing to PyPi
Use the following steps to publish a new version to PyPi.
- Update the version number in pyproject.toml and setup.py.
- Package the distributable:
py -m build - Upload the package:
py -m twine upload dist/* - Confirm the new version at https://pypi.org/project/cardanomsg
License
MIT
Author
Kory Becker http://primaryobjects.com
Metadata
Release files for cardanomsg 0.1.5
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 |
|---|---|---|---|---|
| cardanomsg-0.1.5.tar.gz | 6.0 kB | Without provenance | Details for cardanomsg-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cardanomsg-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for cardanomsg-0.1.5-py3-none-any.whl |
Total release size: 11.7 kB
Release files / cardanomsg-0.1.5.tar.gz
| Download URL | cardanomsg-0.1.5.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7fe38dccbdcad9fdba915ff385b2af0c9229400a8f8c8d11105f314b017f62ef
|
|
BLAKE2b-256 checksum How to use checksums |
1d4061eeed2ceb56fab57452c7095a0676f157a3d695a4a5de8836aee5d39444
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / cardanomsg-0.1.5-py3-none-any.whl
| Download URL | cardanomsg-0.1.5-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
91ff69a6dbfc13a11d5abc2814204f146707648fccfc2aaa93c33d4ce2b1c915
|
|
BLAKE2b-256 checksum How to use checksums |
15c4c5fb96fc8f5b3e7cb44b93cad0c366840b90a2a36f5521c2e953a4eaae76
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for cardanomsg 0.1.5
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.