Skip to main content

A module to send ADA with a message in the metadata.

Project description

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.

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.

from cardanomsg.transaction import find_message
messages = find_message(<BLOCKFROST_PROJECT_ID>, 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.

{
  "type": "PaymentSigningKeyShelley_ed25519",
  "description": "Payment Signing Key",
  "cborHex": "<SENDER_SECRET_KEY>"
}

License

MIT

Author

Kory Becker http://primaryobjects.com

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

cardanomsg-0.1.4.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cardanomsg-0.1.4-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file cardanomsg-0.1.4.tar.gz.

File metadata

  • Download URL: cardanomsg-0.1.4.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.6

File hashes

Hashes for cardanomsg-0.1.4.tar.gz
Algorithm Hash digest
SHA256 04c81b967dd615dab7594d25c61ba96f066189d61196a63778b93b38c309e47c
MD5 38bde638cf341a40dfdf715f87923844
BLAKE2b-256 6892b25ba607ff9b4436859d3be46148487eb093bbee724d86257d917cb5f614

See more details on using hashes here.

File details

Details for the file cardanomsg-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: cardanomsg-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.6

File hashes

Hashes for cardanomsg-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2ee28a40589b542092da336e27d4448c1c90dbe4fadaaab7c8fa3c130a6721ff
MD5 a3e2e62c19ec6973a657f327f05efe5f
BLAKE2b-256 5c636016eb7e84cc4e21f65d45b1c64e71b28145dc8ad92838e1fadc4f1f4997

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page