GithubHelp home page GithubHelp logo

dragonchain / dctl Goto Github PK

View Code? Open in Web Editor NEW
5.0 10.0 3.0 342 KB

Dragonchain command line utility - Get your dragonchain out of its shell

License: Apache License 2.0

JavaScript 69.73% Dockerfile 0.42% Python 29.85%
dragonchain dctl nodejs cli

dctl's Introduction

DCTL

Get your dragonchain out of its shell.

Description

This commandline tool is a thin wrapper around the dragonchain nodejs sdk using commander.

Usage: dctl [options] [command]

Options:
  -V, --version       output the version number
  -h, --help          output usage information

Commands:
  status|s            Get the status of your chain
  transaction|t       Commands for interfacing with transactions
  transactionType|tt  Commands for interfacing with transaction types
  contract|c          Commands for interfacing with contracts
  block|b             Commands for interfacing with blocks
  creds|k             Manage dragonchain credentials on this machine
  interchain|i        Manage interchains configured for a dragonchain
  help [cmd]          display help for [cmd]

System Requirements

  • NodeJs >= 10.0
  • npm (or equivalent like yarn)
  • docker (for dctl contract test)

Install

Install using NPM

npm install -g dctl

Install using Yarn

yarn global add dctl

Usage Examples

Here is a quick example showing SmartContract creation and invocation:

image

Getting Help

dctl --help
dctl <anyCommand...> --help

Credentials

Adding New Dragonchain Credentials

dctl creds add yourDcIdHere -e http://localhost:8080
ENDPOINT: ...
HMAC KEY ID: UAKRHCSOKTYH
HMAC KEY: ***********************************************
Default Dragonchain set to yourDcIdHere.
Success. New Credentials written to /Users/?/.dragonchain/credentials

Listing Dragonchain Credentials

dctl creds ls
  {
  "default": {
    "dragonchain_id": "..."
  },
  "...": {
    "auth_key": "<hidden>",
    "auth_key_id": "UAKRHCSOKTYH",
    "endpoint": "..."
  }
}

Alias/Shorthand Commands

Most commands/subcommands have a one-letter alias.

dctl t c MyTransactionType 'Hi there!'
{ "status": 201, "response": { "transaction_id": "..." }, "ok": true }

Is equivalent to...

dctl transaction create MyTransactionType 'Hi there!'
{ "status": 201, "response": { "transaction_id": "..." }, "ok": true }

Getting Transactions

dctl transaction get 7d1fa05a-ea6f-44a5-a1b8-8568eb701a8c
{ "status": 201, "response": {...}, "ok": true }

Updating Contracts

dctl c u a57afbb0-9cab-4538-adf8-2fdbce9102fc -A newArg1 -A newArg2
{
  "status": 202,
  "response": {
    "success": {
      "dcrn": "SmartContract::L1::AtRest",
      "version": "1",
      "txn_type": "coolcontract",
      "id": "a57afbb0-9cab-4538-adf8-2fdbce9102fc",
      "status": {
        "state": "Updating",
        "msg": "Contract updating",
        "timestamp": "2019-06-07 17:35:54.720967"
      },
      "image": "dragonchain/interchain-watcher:prod-1.0.0",
      "auth_key_id": null,
      "image_digest": null,
      "cmd": "node",
      "args": [
        "newArg1",
        "newArg2"
      ],
      "env": {
        "address": "0x9DF7aeAD32989b4B533d941d3D799eB302E5A804",
        "network": "custom",
        "customNetworkUrl": "http://10.2.1.123:8545",
        "callbackUrl": "https://callmeback.edu"
      },
      "existing_secrets": null,
      "cron": null,
      "seconds": 6,
      "execution_order": "serial"
    }
  },
  "ok": true
}

Creating Contracts

dctl c c coolcontract dragonchain/interchain-watcher:prod-1.0.0 node index.js -n 6 -s -e '{"myvar":"custom","whatever":"foo"}'
{
  "status": 202,
  "response": {
    "success": {
      "dcrn": "SmartContract::L1::AtRest",
      "version": "1",
      "txn_type": "PrivateEthWatcher",
      "id": "a57afbb0-9cab-4538-adf8-2fdbce9102fc",
      "status": {
        "state": "Pending",
        "msg": "Contract creating",
        "timestamp": "2019-06-07 17:35:54.720967"
      },
      "image": "dragonchain/interchain-watcher:prod-1.0.0",
      "auth_key_id": null,
      "image_digest": null,
      "cmd": "node",
      "args": [
        "index.js"
      ],
      "env": {
        "myvar": "custom",
        "whatever": "foo",
      },
      "existing_secrets": null,
      "cron": null,
      "seconds": 6,
      "execution_order": "serial"
    }
  },
  "ok": true
}

Helpful Jq Alias'

Prerequisites

  • Install the jq package to parse the dctl output.
# ~/.bashrc
alias d-scls="dctl c ls | jq '.response.results[] | [(.txn_type, .id)]' | jq -s ."

Examples

# List Smartcontracts Names, Ids
d-cls

[[
  "coolcontract",
  "4b95544c-d1a0-4f4a-ab9d-a098e3a1ce6a"
],[
  "myContract",
  "7ccfae39-5e93-4ca3-ad9e-7d1edf5ce3c2"
]]

Contributing

Dragonchain is happy to welcome contributions from the community. You can get started here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.