https://github.com/primaryobjects/cardanomsg
Store and retrieve text or JSON in the Cardano blockchain metadata.
https://github.com/primaryobjects/cardanomsg
ada bitcoin blockchain cardano crypto metadata pypi pypi-package python transaction
Last synced: 8 months ago
JSON representation
Store and retrieve text or JSON in the Cardano blockchain metadata.
- Host: GitHub
- URL: https://github.com/primaryobjects/cardanomsg
- Owner: primaryobjects
- License: mit
- Created: 2024-12-15T03:39:54.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-22T00:32:47.000Z (11 months ago)
- Last Synced: 2025-04-25T06:50:05.141Z (9 months ago)
- Topics: ada, bitcoin, blockchain, cardano, crypto, metadata, pypi, pypi-package, python, transaction
- Language: Python
- Homepage: https://pypi.org/project/cardanomsg/0.1.3/
- Size: 20.5 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cardanomsg
Store and retrieve text or JSON in the Cardano blockchain metadata.
## Installation
You can install the module using pip:
```sh
pip install cardanomsg
```
## Usage
A [BlockFrost](https://blockfrost.io/) API account is required *(to prevent needing to run the blockchain locally on your PC)*.
## Send message
Send a message in a transaction.
```python
from cardanomsg.transaction import send_message
transaction_hash = send_message("", "wallet.skey", "", 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("", "wallet.skey", "", 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.
```python
from cardanomsg.transaction import get_message
message = get_message("", "079112f6a5192c6eeae57de0607d61e07dea864efc2bbad7aa953795a5c56aae")[0].json_metadata
```
You can also view the message on the blockchain using Cardanoscan.
https://preview.cardanoscan.io/transaction/079112f6a5192c6eeae57de0607d61e07dea864efc2bbad7aa953795a5c56aae?tab=metadata
```
Summary | UTXOs | Metadata (1)
Metadata Hash: 2f86fa9fdfcb606ab2b5f060bd125848e45187cf2c798ab389e6a9af98ba8ad1
Public Label: 1
Value: "Hello World"
```
## Find message
Find messages using a label.
```python
from cardanomsg.transaction import find_message
messages = find_message(, 1782959986)
for message in messages:
print(message.json_metadata)
```
*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.
```json
{
"type": "PaymentSigningKeyShelley_ed25519",
"description": "Payment Signing Key",
"cborHex": ""
}
```
## Publishing to PyPi
Use the following steps to publish a new version to PyPi.
1. Update the version number in [pyproject.toml](https://github.com/primaryobjects/cardanomsg/blob/main/pyproject.toml#L7) and [setup.py](https://github.com/primaryobjects/cardanomsg/blob/main/setup.py#L7).
2. Package the distributable: `py -m build`
3. Upload the package: `py -m twine upload dist/*`
4. Confirm the new version at https://pypi.org/project/cardanomsg
## License
MIT
## Author
Kory Becker
http://primaryobjects.com