0.0.20-Beta • Published 3 years ago

io.dltlabs.unify-cli v0.0.20-Beta

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Follow below steps to setup unify command line interface

Usage

unify ruffle [subCommand]


<subCommand> can be one of the following:
1. init
2. compile
3. link
4. deploy
5. invoke
6. search


Options:
      --help      Show help                                            [boolean]
      --version   Show version number                                  [boolean]
  -n, --name      init flag : Creates and Initialize the project with the name
                  passed as an option
  -f, --file      compile flag: Compiles the contract/s in the project with
                  contract file name passed as an option. Ensure extension of
                  contract is (*.sol).
  -c, --contract  deploy flag: Deploys the contract to network with contract
                  passed. Ensure extenstion of compiled contract is (*.json)
  -j, --path      deploy/link/invoke flag: Deploys the contract to network with
                  the nested path to contract. This is the path in case your
                  contract is in nested path from Work_Space/contract directory.
  -l, --library   link flag: Deploys the contract to network. The name of the
                  library to be linked.
  -d, --deployed  invoke flag: Invoke the deployed smart contract. Name of the
                  deployed contract (with *.json) extension.
  -m, --method    invoke flag: Method Name to be invoked from deployed smart
                  contract
  -p, --params    invoke flag: Multiple arguments to contract method as an
                  array. For specific OS ensure you are skipping the escape character.
  -a, --address   invoke flag: contract address                         [string]
  -s, --account   search flag : Search the account activity in last 25 blocks.
                                                                        [string]


------------------------------------------------------------------------------

## Steps for compiling and deploying HelloWorld on DL Unify Gateway with DL Unify CLI:
1.  Install the package by runing below command in your shell/cmd.

    ------------------------------------------------
    npm install io.dltlabs.unify-cli
    ------------------------------------------------

2.   Create and initialize HelloWorld project

    ------------------------------------------------
    unify ruffle init --name HelloWorld
    ------------------------------------------------

3.  Copy HelloWorld.sol file to contract folder created by previous 
command.
--------------------------------------------------------------------HelloWorld.sol----------------------------------------------------------------------------
    // SPDX-License-Identifier: UNLICENSED

    pragma solidity >=0.5.0 <=0.8.7;

    // Specifies the version of Solidity, using semantic versioning.
    // Learn more: https://solidity.readthedocs.io/en/v0.5.10/layout-of-source-files.html#pragma

    // Defines a contract named `HelloWorld`.
    // A contract is a collection of functions and data (its state). Once deployed, a contract resides at a specific address on the Ethereum blockchain. Learn more: https://solidity.readthedocs.io/en/v0.5.10/structure-of-a-contract.html
    contract HelloWorld {

    // Declares a state variable `message` of type `string`.
    // State variables are variables whose values are permanently stored in contract storage. The keyword `public` makes variables accessible from outside a contract and creates a function that other contracts or clients can call to access the value.
    string public message;

    // Similar to many class-based object-oriented languages, a constructor is a special function that is only executed upon contract creation.
    // Constructors are used to initialize the contract's data. Learn more:https://solidity.readthedocs.io/en/v0.5.10/contracts.html#constructors
    constructor(string memory initMessage) {
    
        // Accepts a string argument `initMessage` and sets the value into the contract's `message` storage variable).
        message = initMessage;
    }

    // A public function that accepts a string argument and updates the `message` storage variable.
    function update(string memory newMessage) public {
        message = newMessage;
    }
}
------------------------------------------------------------------------------------------------------------------------------------------------

4.  Compile HelloWorld Solidity Contract
     ------------------------------------------------
     unify ruffle compile --file HelloWorld.sol

     ------------------------------------------------

    Note: Ensure the extenstion of file is .sol.

5. Deploy the contract to DL Unify GATEWAY.
    ------------------------------------------------
    Simple Example:
     unify ruffle deploy -c  HelloWorld.sol
    ------------------------------------------------
    Complex example:
     unify ruffle deploy -c VotingCore.json:VotingHostRegistry
        Note: make note of FileName:ContractName
    ------------------------------------------------
    ------------------------------------------------
    Nested example:
        In case if your contract is present deep into nested directory, while compiling the contract, use --nest option to the cli the actual path during deployement.

     unify ruffle deploy -c VotingCore.json:VotingHostRegistry --nest first_directory/second_directory
        Note: This nest option will apply for deploy, invoke and link cli sub command too if compiled contract was present in nested directory during compilation.
    ------------------------------------------------

6. Verify the contract is deployed successfully @ [DLTESTNET Explorer](https://market-bcexplorer.devdlt.com/)

7. Invoke the contract method from CLI 
    ------------------------------------------------
    unify ruffle invoke -d HelloWorld.json -m update -o 0x9580F899B7F9e06D6BC143742f810CFE8Eb82e34 -p '["hello"]'
    ------------------------------------------------
    unify ruffle invoke -d VotingCore.json -m getMembership -o 0x724556864383745569dFAed8E030EF1FFE1389c7 -p '["0x28CbD506d22B28434815b5A3Dd4F99f17f542946"]'
    ------------------------------------------------
    Invoking method with no parameters:

    unify ruffle invoke -d VotingCore.json -m getAmountVotings -o 0x724556864383745569dFAed8E030EF1FFE1389c7 -p '[]'
    
    Note: This nest option will apply for deploy, invoke and link cli sub command too if compiled contract was present in nested directory during compilation.
    ------------------------------------------------
    

8. Search account activity with last 25 blocks:

    ------------------------------------------------
    unify ruffle search -s 0x3ec180429a49f45adf252D22c9c5316e13b3c0b0
    ------------------------------------------------

9. Link the deployed library to existing compiled contract before deplpoying.

    ------------------------------------------------
    unify ruffle link -c SafeMathUsage.json -a 0x505Cc79ef6cf389C7A2Ad6D525A6b88A4493E0Bc -l SafeMath
    ------------------------------------------------

## Set up environment
 ![setup](img/unify-ruffle-install.png) 

## Create and initialize HelloWorld project
![Create and Initialize](img/unify-ruffle-init.png)

## ruffle-config.json
![ruffle-config.json](img/unify-ruffle-config.png)

## Compile Solidity contract
![Compilation](img/unify-ruffle-compile.png)

## Deploy Solidity Contract
![Deployment](img/unify-ruffle-deploy.png)