Skip to contents

Writes a key‑value item to a stream. The item is stored on the blockchain (or optionally off‑chain) and can be retrieved by its key.

Usage

mc_publish(conn, stream, keys, data, options = NULL)

Arguments

conn

A connection object created by mc_connect.

stream

Character string. Stream name, reference, or creation txid.

keys

A single key (string) or a vector of keys (for multi‑key items).

data

Data to publish. Can be a hex string, or a list with text (will be hex‑encoded) or json (will be converted to JSON then hex).

options

Optional character string. Use "offchain" to publish as an off‑chain item (requires off‑chain capability on the blockchain).

Value

A character string containing the transaction ID of the published item.

Examples

if (FALSE) { # \dontrun{
# Publish with a text key and simple text data
mc_publish(conn, "mystream", "greeting", list(text = "Hello world!"))

# Publish with JSON data
mc_publish(conn, "mystream", "data", list(json = list(a = 1, b = 2)))

# Publish off‑chain
mc_publish(conn, "mystream", "large", list(text = "big data"), options = "offchain")
} # }