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
- R >= 3.6.0
- MultiChain >= 2.0 – download from multichain.com/download-install
- Pandoc (only if building vignettes locally)
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)Core Features
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 functionsContributing
Contributions are welcome! Please:
- Open an issue to report bugs or suggest features.
- Submit a pull request with a clear description of the change.
- Ensure
devtools::check()passes before submitting.
License
This project is licensed under the MIT License – see the LICENSE file for details.