diff --git a/scripts/issue.sh b/scripts/issue.sh new file mode 100755 index 00000000..6d2a7caa --- /dev/null +++ b/scripts/issue.sh @@ -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 [ ]" + 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, 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 \ No newline at end of file diff --git a/scripts/list.sh b/scripts/list.sh new file mode 100755 index 00000000..6bc8a23e --- /dev/null +++ b/scripts/list.sh @@ -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 [ ]" + 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, 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 \ No newline at end of file diff --git a/scripts/redeem.sh b/scripts/redeem.sh new file mode 100755 index 00000000..4b062b77 --- /dev/null +++ b/scripts/redeem.sh @@ -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 [ ]" + 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, 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 + + + diff --git a/scripts/set-env.sh b/scripts/set-env.sh new file mode 100755 index 00000000..58a596ac --- /dev/null +++ b/scripts/set-env.sh @@ -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 diff --git a/scripts/transfer.sh b/scripts/transfer.sh new file mode 100755 index 00000000..03b7ac3a --- /dev/null +++ b/scripts/transfer.sh @@ -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 [ ]" + 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, 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 + + +