Skip to content

Latest commit

 

History

History
161 lines (129 loc) · 3.91 KB

README_KLAYTN.md

File metadata and controls

161 lines (129 loc) · 3.91 KB

vvisp

Quick Usage

1. Install vvisp

$ npm install -g @haechi-labs/vvisp
#or if you use yarn
$ yarn global add @haechi-labs/vvisp

Use version >= v2.1.0

2. Initialize your directory

$ vvisp init my-project --klaytn
$ cd my-project

$ npm install #or yarn install

3. Make your Contracts at contracts/

Now, you can use gen-script, compile and flatten commands.

4. Set vvisp-config.js file

Please set environment variables in vvisp-config.js file.

Example

const MNEMONIC = 'YOUR_MNEMONIC';

module.exports = {
  networks: {
    development: {
      platform: 'klaytn',
      url: 'URL_TO_KLAYTN_NODE',
      gasLimit: 10000000, // increase if you need
    }
  },
  compilers: {
    solc: {
      version: '0.4.24',
      settings: {
        optimizer: {
          enabled: true,
          runs: 200
        },
        evmVersion: 'byzantium'
      }
    }
  },
  from: { // or from: 'YOUR_PRIVATE_KEY'
    mnemonic: MNEMONIC,
    index: 0
  },
};

See more information at here for more information about vvisp-config.js. Now you can use deploy-contract command.

5. Set service.vvisp.json file

Please set information about your DApp service in service.vvisp.json.

Example

{
  "serviceName": "Haechi",
  "variables" : {
    "exampleVarName": 123
  },
  "contracts": {
    "ContractKeyName1": {
      "path": "./contracts/Contract1.sol",
      "name": "Contract1",
      "constructorArguments": [
        "${contracts.ContractKeyName1.address}",
        "${variables.exampleVarName}"
      ],
      "initialize": {
        "functionName": "initialize",
        "arguments": ["argument1", "argument2"]
      }
    },
    "ContractKeyName2": {
      "path": "./contracts/Contract2.sol",
      "name": "Contract2",
      "initialize": {
        "functionName": "initialize",
        "arguments": ["argument1", "argument2"]
      }
    }
  }
}

See more information at here for more information about service.vvisp.json. Now you can use deploy-service command.

Deploy First Version

  1. Write service.vvisp.json file.
  2. Make from variable in vvisp-config.js. See more details at here.
  3. Run vvisp deploy-service at root directory. It will act like this demo.
  4. Wait for deploying the sample app. Then, state.vvisp.json will be generated. This file is necessary to upgrade your service

Upgrade to Second Version

Add contract property at service.vvisp.json#contracts like:

"contracts": {
  ...
  "NewContract": {
    "path": "./contracts/NewContract.sol",
    "name": "NewContract"
  }
}

Then, run vvisp deploy-service. It will act like this demo.

See more details about vvisp deploy-service at here

Use console

If the service is already deployed and has state.vvisp.json(necessary), you can operate your contracts with vvisp console.

First, make apis of contracts which are written in state.vvisp.json.

 $ vvisp gen-script

Then run vvisp console and operate functions of your contracts.

See more details about vvisp console at here

Contract

  • Create your own contracts in contracts/ directory.

Test

  • We support use truffle framework.
  • Create test files in test/ directory.
  • Run npm run test to test all test files in test/ directory or npm run test <fileName> to test specific file.

Commands

Please see here for details.

Contact