Skip to contents

multichainr is a comprehensive R interface to the MultiChain blockchain JSON-RPC API. It allows you to manage blockchain nodes, create and query data streams, issue assets, manage permissions, build raw transactions, and much more – all from within R.


Prerequisites

Make sure the MultiChain binaries (multichaind, multichain-util) are accessible. Set the path via:

mc_set_path("/path/to/multichain/binaries")

or add MULTICHAIN_PATH to your .Renviron file.


Installation

# From GitHub (development version)
remotes::install_github("datascienceadvice/multichainr")

# From CRAN (once published)
install.packages("multichainr")

Quick Start

library(multichainr)

# Set path to MultiChain binaries
mc_set_path(Sys.getenv("MULTICHAIN_PATH"))

# Create and start a local blockchain
mc_node_init("my_first_chain")
mc_node_start("my_first_chain")

# Connect to the node
config <- mc_get_config("my_first_chain")
conn <- mc_connect(config)

# Check node status
info <- mc_get_info(conn)
cat("Node balance:", info$balance, "\n")
cat("Block height:", info$blocks, "\n")

# Create a stream and publish data
mc_create_stream(conn, "mystream", open = TRUE)
mc_publish(conn, "mystream", "key1", list(text = "Hello, MultiChain!"))

# Query the stream
items <- mc_list_stream_items(conn, "mystream")
print(items)

# Clean up
mc_node_stop(conn)

Documentation

Full reference documentation is available at the package website (once published) or via R’s built-in help:

?mc_connect    # help for a specific function
help(package = "multichainr")  # list all exported functions

Contributing

Contributions are welcome! Please:

  1. Open an issue to report bugs or suggest features.
  2. Submit a pull request with a clear description of the change.
  3. Ensure devtools::check() passes before submitting.

License

This project is licensed under the MIT License – see the LICENSE file for details.