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.
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) orjson(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).
See also
mc_publish_from to specify publisher address,
mc_publish_multi for multiple items.
Other streams:
mc_create_stream(),
mc_create_stream_from(),
mc_get_stream_info(),
mc_get_stream_item(),
mc_get_stream_key_summary(),
mc_get_stream_publisher_summary(),
mc_list_stream_block_items(),
mc_list_stream_items(),
mc_list_stream_key_items(),
mc_list_stream_keys(),
mc_list_stream_publisher_items(),
mc_list_stream_publishers(),
mc_list_stream_query_items(),
mc_list_stream_tx_items(),
mc_list_streams(),
mc_publish_from(),
mc_publish_multi(),
mc_publish_multi_from()
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")
} # }