## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  eval = FALSE 
)

## ----setup--------------------------------------------------------------------
# library(multichainr)
# 
# # Provide the path to the folder containing MultiChain executables
# mc_set_path(Sys.getenv("MULTICHAIN_PATH"))

## ----init---------------------------------------------------------------------
# chain_name <- "vignette_chain"
# 
# # Initialize a new blockchain (creates the configuration files)
# mc_node_init(chain_name)

## ----start--------------------------------------------------------------------
# # Start the node
# mc_node_start(chain_name)
# 
# # Wait a few seconds for the node to initialize and open the RPC port
# Sys.sleep(3)

## ----connect------------------------------------------------------------------
# # Get the configuration for the specific chain
# config <- mc_get_config(chain_name)
# 
# # Create a connection object
# conn <- mc_connect(config)
# 
# # Verify the node status
# info <- mc_get_info(conn)
# cat("Connected to chain:", info$chainname, "\n")
# cat("Protocol Version:", info$protocolversion, "\n")
# cat("Current Block Height:", info$blocks, "\n")

## ----cleanup------------------------------------------------------------------
# # Send the stop signal to the node
# mc_node_stop(conn)
# 
# # Brief pause to allow the process to finalize file writing
# Sys.sleep(2)
# 
# # Deleting the blockchain files (WARNING: This is irreversible!)
# # Determine the default MultiChain data directory based on the OS
# if (.Platform$OS.type == "windows") {
#   base_dir <- file.path(Sys.getenv("APPDATA"), "MultiChain")
# } else if (Sys.info()["sysname"] == "Darwin") {
#   base_dir <- file.path(Sys.getenv("HOME"), "Library/Application Support/MultiChain")
# } else {
#   base_dir <- file.path(Sys.getenv("HOME"), ".multichain")
# }
# 
# chain_dir <- file.path(base_dir, chain_name)
# 
# if (dir.exists(chain_dir)) {
#   unlink(chain_dir, recursive = TRUE)
#   message("Temporary blockchain files deleted successfully.")
# }

