github.com/inklabsfoundation/inkchain@v0.17.1-0.20181025012015-c3cef8062f19/examples/creative/scripts/func_token.sh (about)

     1  #!/usr/bin/env bash
     2  #
     3  #Copyright Ziggurat Corp. 2017 All Rights Reserved.
     4  #
     5  #SPDX-License-Identifier: Apache-2.0
     6  #
     7  
     8  # Detecting whether can import the header file to render colorful cli output
     9  if [ -f ./func_init.sh ]; then
    10   source ./func_init.sh
    11  elif [ -f scripts/func_init.sh ]; then
    12   source scripts/func_init.sh
    13  else
    14   alias echo_r="echo"
    15   alias echo_g="echo"
    16   alias echo_b="echo"
    17  fi
    18  
    19  # issueToken INK 1000 18 ${USER_ADDRESS_01}
    20  issueToken(){
    21      sleep 5
    22      peer chaincode invoke -o orderer.example.com:7050  --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C ${CHANNEL_NAME} -n ascc -c '{"Args":["registerAndIssueToken","'$1'","'$2'","'$3'","'$4'"]}' >log.txt
    23      res=$?
    24      cat log.txt
    25      verifyResult $res "Issue a new token using ascc has Failed."
    26      echo_g "===================== A new token has been successfully issued======================= "
    27      echo
    28  }
    29  
    30  # makeTransfer ${USER_ADDRESS_02} INK  500 ${USER_TOKEN_01}
    31  makeTransfer(){
    32      echo_b "pls wait 5 secs..."
    33      sleep 5
    34      peer chaincode invoke -o orderer.example.com:7050  --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C ${CHANNEL_NAME} -n token -c '{"Args":["transfer","'$1'","'$2'","'$3'"]}' -i "10" -z "$4" >log.txt
    35      res=$?
    36      cat log.txt
    37      verifyResult $res "Make transfer has Failed."
    38      echo_g "===================== Make transfer success ======================= "
    39      echo
    40  }
    41  
    42  # chaincodeQuery ${USER_ADDRESS_01} INK
    43  # chaincodeQuery ${USER_ADDRESS_02} INK
    44  chaincodeQuery () {
    45      echo_b "Attempting to Query account A's balance on peer "
    46      sleep 3
    47      peer chaincode query -C ${CHANNEL_NAME} -n token -c '{"Args":["getBalance","'$1'","'$2'"]}' >log.txt
    48      res=$?
    49      cat log.txt
    50      verifyResult $res "query account A Failed."
    51  }