0.0.2 • Published 2 years ago

evt-toolchain v0.0.2

Weekly downloads
-
License
GPLv3
Repository
github
Last release
2 years ago

evt-toolchain

Summary

In this toolchain, you can use some simple shell command line to deploy contract, create EVT, call EVT Encryption functions, call EVT Variable functions. etc.

Development with EVT

Prerequisites

  1. Node.js installed on your local machine.
  2. Get RPC Endpoint and ChainId which you want to try.
  3. Own an Address and PrivateKey

Get source code and Install

```bash

# install evt-toolchain
npm install evt-toolchain -D

# create .env file in your project root
source .env
# set new CHAIN_ID, RPC_URL, PRIVATE_KEY in .env file


```

Use EVT and EVTA

  1. Deploy Contract
    # ex.: npx evtc deploy ./templete.sol contractName
    npx evtc deploy contract_path contract_name
  2. Create

    1. EVT

      # mint EVT
      npx evtc evt call mintEVT
      # you can get EVT_ADDRESS and EVTA_ADDRESS in log file
      # copy contract addresses to .env file
      # the token will be owned by your address
    2. EVTA

      # mint EVTA. quantity: the amount you want to mint
      npx evtc evt call mintEVTA quantity
      # the tokens will be owned by your address

By run Deploy and Mint, you can check your contract and EVT in blockchain explorar.

If you use Newchain testnet configuration, you can see in Newton Testnet Explorar with EVT_ADDRESS, EVTA_ADDRESS or ACCOUNT.

Use EVT Encryption

We provide an open source project NewKeeper to combine with EVT Encryption.

  1. Run NewKeeper

    # pull newkeeper-dev v0.1
    docker pull pschy/newkeeper-dev
    
    # run newkeeper with a PORT
    docker run -it -d -p `PORT`:8000 --name newkeeper pschy/newkeeper-dev
    
    # check status and get CONTAINER ID
    docker ps
    
    # show logs
    docker logs -f `CONTAINER ID`
    
    # set NEWKEEPER url in .env file 
  2. Deploy Contract

    # deploy contract
    npx evtc encryption deploy
    # get TOKEN_ADDRESS and CONTRACT_ADDRESS, set in .env file
  3. Call Functions

    # call contract functions with params
    npx evtc encryption call functions params

    Use the shell common line to call Below functions. you can get returns in commander

    Functions

    • mint_EVT()
      • desc

        mint a Token for encryption key register permission.

    • mint_token()

      • desc

        mint a new EVT

    • get_balance()

      • desc

        check address token balance, the permission for Key register

      • returns

        balance

    • generator()

      • desc

        call Newkeeper to generator KeyId

      • returns

        peerPrivateKey, keyId, privateKey, peer, prime, peerPublicKey

    • register_encrypted_key(params)

      • desc

        Use a keyId to encrypted a Token.

      • params

        tokenId, keyId

    • add_permission(params)

      • desc

        Add permission to an Address with a keyId

      • params

        tokenId, keyId, licensee(an address)

    • has_permission(params)

      • desc

        Check the permission

      • params

        tokenId, keyId, licensee(an address)

      • returns

        result

    • register(params)

      • desc

        Bind keyId, tokenId, Contract in NewKeeper

      • params

        tokenId, KeyId, peerPrivateKey, privateKey (you can get these from generator function)

    • get_key(params)

      • desc

        Get PrivateKey

      • params prime, peerSwapKey, KeyId

You can also run a commond line to test EVT encryption:

npx evtc encryption test

It will deploy contracts, mint token and evt, generate key with Newkeeper etc.

Use EVT Variable

  1. Deploy Contract

    # deploy contract
    npx evtc variable deploy
    # get TOKEN_ADDRESS and CONTRACT_ADDRESS, set in .env file
  2. Call functions

    # Mint evt
    npx evtc variable call mint
    
    # Add a Property. like: height, with, age. etc.
    npx evtc variable call addProperty propertyName
    
    # Set Property to a EVT
    # ex.: npx evtc variable call setProperty 0 age 30
    npx evtc variable call setProperty tokenId propertyName propertyValue
    
    # Get Property
    # ex.: npx evtc variable call getProperty 0 age
    npx evtc variable call getProperty tokenId propertyName

Reference