| commit | ef8dad62acb816ccbbe62a1db24b7a09b0e597b6 | [log] [tgz] |
|---|---|---|
| author | gopuman <gopuman@node0.gopuman-210941.resilientdb-pg0.utah.cloudlab.us> | Tue Jul 02 18:11:42 2024 -0600 |
| committer | gopuman <gopuman@node0.gopuman-210941.resilientdb-pg0.utah.cloudlab.us> | Tue Jul 02 18:11:42 2024 -0600 |
| tree | 33ad2f3f86d038e2b305ab128e021eb95f150318 | |
| parent | a38804e78a872ef90e5cbab1c702c7554a393c9b [diff] |
Added README and compile command
The ResDB Smart Contracts CLI is a tool for creating, deploying, and managing smart contracts within the ResilientDB ecosystem. It is designed to work seamlessly with other ResilientDB projects, providing a streamlined interface for developers.
Before installing and using the Smart Contracts CLI, ensure you have the following prerequisites installed on your system:
Node.js and npm are required to run the Smart Contracts CLI. Follow the instructions below to install them based on your operating system.
sudo apt update sudo apt install -y nodejs npm
brew update
brew install node
config.js βοΈResDB_HomeThe ResDB_Home path points to the directory where the ResilientDB installation resides. This path allows the CLI to locate and execute ResilientDB-related binaries and scripts.
config.js ImplementationThe config.js file contains logic to prompt the user for the ResDB_Home path the first time they use the CLI and then stores this path for future use. Hereβs how it works:
ResDB_Home environment variable is already set.~/.smart-contracts-cli-config.json) to see if the ResDB_Home path has been saved previously.ResDB_Home path if neither the environment variable nor the configuration file provides it.config.js Codeconst path = require('path'); const inquirer = require('inquirer'); const fs = require('fs-extra'); const os = require('os'); const CONFIG_FILE_PATH = path.join(os.homedir(), '.smart-contracts-cli-config.json'); async function getResDBHome() { if (process.env.ResDB_Home) { return process.env.ResDB_Home; } if (await fs.pathExists(CONFIG_FILE_PATH)) { const config = await fs.readJson(CONFIG_FILE_PATH); if (config.resDBHome) { process.env.ResDB_Home = config.resDBHome; return config.resDBHome; } } return null; } async function setResDBHome(resDBHome) { process.env.ResDB_Home = resDBHome; await fs.writeJson(CONFIG_FILE_PATH, { resDBHome }); } async function promptForResDBHome() { const answers = await inquirer.prompt([ { type: 'input', name: 'resDBHome', message: 'Please enter the ResDB_Home path:', }, ]); const resDBHome = answers.resDBHome; await setResDBHome(resDBHome); return resDBHome; } module.exports = { getResDBHome, setResDBHome, promptForResDBHome, };
To get started with the ResDB Smart Contracts CLI:
npm install.smart-contracts-cli <command> <options>.ResDB_Home path.The create command initializes a new account using ResilientDB's smart contract tools.
smart-contracts-cli create --config <path_to_config>
path_to_config: Path to the configuration file.The compile command compiles a Solidity smart contract into a JSON file using solc.
smart-contracts-cli compile <inputFile.sol> <outputFile.json>
inputFile.sol: Path to the Solidity smart contract file.outputFile.json: Name of the resulting JSON file.Make sure solc (Solidity compiler) is installed on your system. Refer to the Prerequisites section in the README for installation instructions.