npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rescontract-cli

v1.2.1

Published

A CLI tool for managing smart contracts in the ResilientDB ecosystem.

Downloads

74

Readme

ResContract CLI 🚀

The ResContract CLI is a command-line tool for creating, deploying, and managing smart contracts within the ResilientDB ecosystem. It provides a streamlined interface for developers and students to interact with smart contracts efficiently.

Table of Contents

Features ✨

  • Create Smart Contracts: Generate new smart contract templates.
  • Compile Contracts: Compile Solidity contracts to JSON.
  • Deploy Smart Contracts: Deploy contracts to the blockchain.
  • Execute Functions: Interact with and manage deployed contracts.

Prerequisites

Before installing and using the ResContract CLI, ensure you have the following prerequisites installed on your system:

  • Node.js (version >= 14): Download and install Node.js
  • npm: Comes with Node.js. Ensure it's up-to-date.
  • Solidity Compiler (solc): Required to compile smart contracts.

Installing solc

Linux (Ubuntu/Debian)

sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install -y solc

macOS

brew update
brew upgrade
brew tap ethereum/ethereum
brew install solidity

Installation 🛠️

Install the ResContract CLI globally using npm:

npm install -g rescontract-cli

Configuration ⚙️

Setting the ResDB_Home Variable

Before using the ResContract CLI, you must set the ResDB_Home environment variable or provide the path to your ResilientDB installation in a config.yaml file. The CLI will not prompt you for this path and will exit with an error if it's not set.

Option 1: Set ResDB_Home Environment Variable

Set the ResDB_Home environment variable to point to the directory where ResilientDB is installed.

Linux/macOS:

export ResDB_Home=/path/to/resilientdb

Add the above line to your .bashrc or .zshrc file to make it persistent.

Option 2: Use a config.yaml File

Update the config.yaml file in the same directory where you run the rescontract command or in your home directory.

Example config.yaml:

ResDB_Home: /path/to/resilientdb

Ensure the ResDB_Home path is correct.

Note: The CLI checks for config.yaml in the current directory first, then in your home directory.

Usage

After installation, you can use the rescontract command in your terminal.

rescontract <command> [options]

Commands

create Command

Initializes a new account using ResilientDB's smart contract tools.

Usage:

rescontract create --config <path_to_config>
  • --config, -c: Path to the configuration file.

Example:

rescontract create --config ~/resilientdb/config/service.config

compile Command

Compiles a Solidity smart contract into a JSON file using solc.

Usage:

rescontract compile --sol <inputFile.sol> --output <outputFile.json>
  • --sol, -s: Path to the Solidity smart contract file.
  • --output, -o: Name of the resulting JSON file.

Example:

rescontract compile --sol contracts/MyToken.sol --output build/MyToken.json

deploy Command

Deploys the smart contract to the blockchain.

Usage:

rescontract deploy --config <service.config> --contract <contract.json> \
--name <tokenName> --arguments "<parameters>" --owner <address>
  • --config, -c: Client configuration path.
  • --contract, -p: Path to the contract JSON file.
  • --name, -n: Name of the contract.
  • --arguments, -a: Parameters to create the contract object (enclosed in quotes).
  • --owner, -m: Contract owner's address.

Example:

rescontract deploy --config ~/resilientdb/config/service.config \
--contract build/MyToken.json --name MyToken \
--arguments "1000000" --owner 0xYourAddress

execute Command

Executes a smart contract function.

Usage:

rescontract execute --config <service.config> --sender <senderAddress> \
--contract <contractAddress> --function-name <functionName> --arguments "<parameters>"
  • --config, -c: Path to the client configuration file.
  • --sender, -m: Address of the sender executing the function.
  • --contract, -s: Address of the deployed contract.
  • --function-name, -f: Name of the function to execute (include parameter types).
  • --arguments, -a: Arguments to pass to the function (enclosed in quotes).

Example:

rescontract execute --config ~/resilientdb/config/service.config \
--sender 0xYourAddress --contract 0xContractAddress \
--function-name "transfer(address,uint256)" \
--arguments "0xRecipientAddress,100"

License

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