mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-23 01:55:10 +00:00
Scripts for automation of FabToken
Signed-off-by: Lucigol <luti4497@gmail.com>
This commit is contained in:
parent
3da5f8a450
commit
384e887b9f
5 changed files with 141 additions and 0 deletions
31
scripts/issue.sh
Executable file
31
scripts/issue.sh
Executable file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#Script to issue tokens to a specified user in FabToken ecosystem
|
||||||
|
|
||||||
|
# Print help message
|
||||||
|
|
||||||
|
function printHelp() {
|
||||||
|
echo "Script to issue tokens to a specific user."
|
||||||
|
echo " "
|
||||||
|
echo "Usage: "
|
||||||
|
echo " issue.sh <mode> [<RECEIVER_CONFIG_FILE> <ISSUER_MSP> <TRANSACTION_CHANNEL> <TOKEN_TYPE> <QUANTITY> <RECEIVER_MSP>]"
|
||||||
|
echo " Write the arguments in the order above. If the user wishes, he/she can substitute some of then by"
|
||||||
|
echo " environment variables created when executing set_env.sh script."
|
||||||
|
echo " In this example, <TRANSACTION_CHANNEL> should be mychannel."
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
|
||||||
|
MODE=$1
|
||||||
|
RECEIVER_CONFIG_FILE=$2
|
||||||
|
ISSUER_MSP=$3
|
||||||
|
TRANSACTION_CHANNEL=$4
|
||||||
|
TOKEN_TYPE=$5
|
||||||
|
QUANTITY=$6
|
||||||
|
RECEIVER_MSP=$7
|
||||||
|
|
||||||
|
if [ "$MODE" == "exec" ]; then
|
||||||
|
token issue --config $RECEIVER_CONFIG_FILE --mspPath $ISSUER_MSP --channel $TRANSACTION_CHANNEL --type $TOKEN_TYPE --quantity $QUANTITY --recipient $RECEIVER_MSP
|
||||||
|
|
||||||
|
else
|
||||||
|
printHelp
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
fi
|
||||||
27
scripts/list.sh
Executable file
27
scripts/list.sh
Executable file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#Script to list tokens of a specified user in FabToken ecosystem
|
||||||
|
|
||||||
|
#Print help message
|
||||||
|
|
||||||
|
function printHelp() {
|
||||||
|
echo "Script to list the tokens owned by a specific user."
|
||||||
|
echo "Usage: "
|
||||||
|
echo " issue.sh <mode> [<TARGET_USER_CONFIG_FILE> <TARGET_USER_MSP> <TRANSACTION_CHANNEL>]"
|
||||||
|
echo " Write the arguments in the order above. If the user wishes, he/she can substitute some of then by"
|
||||||
|
echo " environment variables created when executing set_env.sh script."
|
||||||
|
echo " In this example, <TRANSACTION_CHANNEL> should be mychannel."
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
|
||||||
|
MODE=$1
|
||||||
|
TARGET_USER_CONFIG_FILE=$2
|
||||||
|
TARGET_USER_MSP=$3
|
||||||
|
TRANSACTION_CHANNEL=$4
|
||||||
|
|
||||||
|
if [ "$MODE" == "exec" ]; then
|
||||||
|
token list --config $TARGET_USER_CONFIG_FILE --mspPath $TARGET_USER_MSP --channel $TRANSACTION_CHANNEL
|
||||||
|
|
||||||
|
else
|
||||||
|
printHelp
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
fi
|
||||||
32
scripts/redeem.sh
Executable file
32
scripts/redeem.sh
Executable file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#Script to redeem tokens from a specified user in FabToken
|
||||||
|
|
||||||
|
#Print help message
|
||||||
|
|
||||||
|
function printHelp() {
|
||||||
|
echo "Script to redeem tokens to a specific user."
|
||||||
|
echo " "
|
||||||
|
echo "Usage: "
|
||||||
|
echo " issue.sh <mode> [<TARGET_USER> <TARGET_USER_MSP> <TRANSACTION_CHANNEL> <REMOVABLE_TOKEN_ID> <QUANTITY>]"
|
||||||
|
echo " Write the arguments in the order above. If the user wishes, he/she can substitute some of then by"
|
||||||
|
echo " environment variables created when executing set_env.sh script."
|
||||||
|
echo " In this example, <TRANSACTION_CHANNEL> should be mychannel."
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
|
||||||
|
MODE=$1
|
||||||
|
TARGET_USER_CONFIG_FILE=$2
|
||||||
|
TARGET_USER_MSP=$3
|
||||||
|
TRANSACTION_CHANNEL=$4
|
||||||
|
REMOVABLE_TOKEN_ID=$5
|
||||||
|
QUANTITY=$6
|
||||||
|
|
||||||
|
if [ "$MODE" == "exec" ]; then
|
||||||
|
token redeem --config $TARGET_USER_CONFIG_FILE --mspPath $TARGET_USER_MSP --channel $TRANSACTION_CHANNEL --tokenIDs $REMOVABLE_TOKEN_ID --quantity $QUANTITY
|
||||||
|
else
|
||||||
|
printHelp
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
19
scripts/set-env.sh
Executable file
19
scripts/set-env.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
||||||
|
#Script to set parameters as environment variables, such as path to users crypto-material
|
||||||
|
#and configuration files
|
||||||
|
|
||||||
|
export CONFIG1_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/configorg1.json
|
||||||
|
export ORG1_ADMIN=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
|
||||||
|
export USER1_ORG1=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp
|
||||||
|
export CONFIG2_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/configorg2.json
|
||||||
|
export SHARES_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/shares.json
|
||||||
|
export USER1_ORG2=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp
|
||||||
|
export WORK_CHANNEL=mychannel
|
||||||
|
|
||||||
|
echo "CONFIG1_FILE="$CONFIG1_FILE
|
||||||
|
echo "ORG1_ADMIN="$ORG1_ADMIN
|
||||||
|
echo "USER1_ORG1="$USER1_ORG1
|
||||||
|
echo "CONFIG2_FILE="$CONFIG2_FILE
|
||||||
|
echo "SHARES_FILE="$SHARES_FILE
|
||||||
|
echo "USER1_ORG2="$USER1_ORG2
|
||||||
|
echo "CONFIG1_FILE="$CONFIG1_FILE
|
||||||
|
echo "WORK_CHANNEL"=$WORK_CHANNEL
|
||||||
32
scripts/transfer.sh
Executable file
32
scripts/transfer.sh
Executable file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#Script to make transfers in FabToken ecosystem
|
||||||
|
|
||||||
|
#Input variables
|
||||||
|
|
||||||
|
#Print help message
|
||||||
|
function printHelp() {
|
||||||
|
echo "Script to transfer tokens from a specific user to another."
|
||||||
|
echo " "
|
||||||
|
echo "Usage: "
|
||||||
|
echo " issue.sh <mode> [<SENDER_CONFIG_FILE> <SENDER_MSP> <TRANSACTION_CHANNEL> <INPUT_TOKEN_ID> <SHARES_FILE_PATH>]"
|
||||||
|
echo " Write the arguments in the order above. If the user wishes, he/she can substitute some of then by"
|
||||||
|
echo " environment variables created when executing set_env.sh script."
|
||||||
|
echo " In this example, <TRANSACTION_CHANNEL> should be mychannel."
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
MODE=$1
|
||||||
|
SENDER_CONFIG_FILE=$2
|
||||||
|
SENDER_MSP=$3
|
||||||
|
TRANSACTION_CHANNEL=$4
|
||||||
|
INPUT_TOKEN_ID=$5
|
||||||
|
SHARES_FILE_PATH=$6
|
||||||
|
|
||||||
|
if [ "$MODE" == "exec" ]; then
|
||||||
|
token transfer --config $SENDER_CONFIG_FILE --mspPath $SENDER_MSP --channel $TRANSACTION_CHANNEL --tokenIDs $INPUT_TOKEN_ID --shares $SHARES_FILE_PATH
|
||||||
|
else
|
||||||
|
printHelp
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in a new issue