token¶
The token
CLI allows you to use the Fabtoken client to issue, list, transfer,
and redeem tokens.
token issue¶
usage: token issue [<flags>]
Import token command
Flags:
--help Show context-sensitive help (also try --help-long and
--help-man).
--configFile=CONFIGFILE Specifies the config file to load the configuration
from
--peerTLSCA=PEERTLSCA Sets the TLS CA certificate file path that verifies
the TLS peer's certificate
--tlsCert=TLSCERT (Optional) Sets the client TLS certificate file path
that is used when the peer enforces client
authentication
--tlsKey=TLSKEY (Optional) Sets the client TLS key file path that is
used when the peer enforces client authentication
--userKey=USERKEY Sets the user's key file path that is used to sign
messages sent to the peer
--userCert=USERCERT Sets the user's certificate file path that is used to
authenticate the messages sent to the peer
--MSP=MSP Sets the MSP ID of the user, which represents the
CA(s) that issued its user certificate
--channel=CHANNEL Overrides channel configuration
--mspPath=MSPPATH Overrides msp path configuration
--mspId=MSPID Overrides msp id configuration
--config=CONFIG Sets the client configuration path
--type=TYPE Sets the token type to issue
--quantity=QUANTITY Sets the quantity of tokens to issue
--recipient=RECIPIENT Sets the recipient of tokens to issue
token list¶
usage: token list [<flags>]
List tokens command
Flags:
--help Show context-sensitive help (also try --help-long and
--help-man).
--configFile=CONFIGFILE Specifies the config file to load the configuration
from
--peerTLSCA=PEERTLSCA Sets the TLS CA certificate file path that verifies
the TLS peer's certificate
--tlsCert=TLSCERT (Optional) Sets the client TLS certificate file path
that is used when the peer enforces client
authentication
--tlsKey=TLSKEY (Optional) Sets the client TLS key file path that is
used when the peer enforces client authentication
--userKey=USERKEY Sets the user's key file path that is used to sign
messages sent to the peer
--userCert=USERCERT Sets the user's certificate file path that is used to
authenticate the messages sent to the peer
--MSP=MSP Sets the MSP ID of the user, which represents the
CA(s) that issued its user certificate
--channel=CHANNEL Overrides channel configuration
--mspPath=MSPPATH Overrides msp path configuration
--mspId=MSPID Overrides msp id configuration
--config=CONFIG Sets the client configuration path
token transfer¶
usage: token transfer [<flags>]
Transfer tokens command
Flags:
--help Show context-sensitive help (also try --help-long and
--help-man).
--configFile=CONFIGFILE Specifies the config file to load the configuration
from
--peerTLSCA=PEERTLSCA Sets the TLS CA certificate file path that verifies
the TLS peer's certificate
--tlsCert=TLSCERT (Optional) Sets the client TLS certificate file path
that is used when the peer enforces client
authentication
--tlsKey=TLSKEY (Optional) Sets the client TLS key file path that is
used when the peer enforces client authentication
--userKey=USERKEY Sets the user's key file path that is used to sign
messages sent to the peer
--userCert=USERCERT Sets the user's certificate file path that is used to
authenticate the messages sent to the peer
--MSP=MSP Sets the MSP ID of the user, which represents the
CA(s) that issued its user certificate
--channel=CHANNEL Overrides channel configuration
--mspPath=MSPPATH Overrides msp path configuration
--mspId=MSPID Overrides msp id configuration
--config=CONFIG Sets the client configuration path
--tokenIDs=TOKENIDS Sets the token IDs to transfer
--shares=SHARES Sets the shares of the recipients
token redeem¶
usage: token redeem [<flags>]
Redeem tokens command
Flags:
--help Show context-sensitive help (also try --help-long and
--help-man).
--configFile=CONFIGFILE Specifies the config file to load the configuration
from
--peerTLSCA=PEERTLSCA Sets the TLS CA certificate file path that verifies
the TLS peer's certificate
--tlsCert=TLSCERT (Optional) Sets the client TLS certificate file path
that is used when the peer enforces client
authentication
--tlsKey=TLSKEY (Optional) Sets the client TLS key file path that is
used when the peer enforces client authentication
--userKey=USERKEY Sets the user's key file path that is used to sign
messages sent to the peer
--userCert=USERCERT Sets the user's certificate file path that is used to
authenticate the messages sent to the peer
--MSP=MSP Sets the MSP ID of the user, which represents the
CA(s) that issued its user certificate
--channel=CHANNEL Overrides channel configuration
--mspPath=MSPPATH Overrides msp path configuration
--mspId=MSPID Overrides msp id configuration
--config=CONFIG Sets the client configuration path
--tokenIDs=TOKENIDS Sets the token IDs to redeem
--quantity=QUANTITY Sets the quantity of tokens to redeem
token saveConfig¶
usage: token saveConfig
Save the config passed by flags into the file specified by --configFile
Flags:
--help Show context-sensitive help (also try --help-long and
--help-man).
--configFile=CONFIGFILE Specifies the config file to load the configuration
from
--peerTLSCA=PEERTLSCA Sets the TLS CA certificate file path that verifies
the TLS peer's certificate
--tlsCert=TLSCERT (Optional) Sets the client TLS certificate file path
that is used when the peer enforces client
authentication
--tlsKey=TLSKEY (Optional) Sets the client TLS key file path that is
used when the peer enforces client authentication
--userKey=USERKEY Sets the user's key file path that is used to sign
messages sent to the peer
--userCert=USERCERT Sets the user's certificate file path that is used to
authenticate the messages sent to the peer
--MSP=MSP Sets the MSP ID of the user, which represents the
CA(s) that issued its user certificate
Example Usage¶
token issue example¶
You can use the following command to issue 100 Fabcoins
belonging to
User1@org1.example.com
. The tokens are issued by Admin@org1.example.com
.
Use the
--config
flag to provide the path to a file that contains the connection information for your fabric network, including your Prover peer. You can find a sample configuration file below. Use the--mspPath
flag to provide the path to the MSP of the token issuer.export CONFIG_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/configorg1.json export MSP_PATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp . token issue --config $CONFIG_FILE --mspPath $MSP_PATH --channel mychannel --type Fabcoins --quantity 100 --recipient Org1MSP:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp . 2019-03-28 18:19:29.438 UTC [token.client] BroadcastReceive -> INFO 001 calling OrdererClient.broadcastReceive Orderer Status [SUCCESS] Committed [true]
token list example¶
You can use the token list
command to discover the tokenIDs of the tokens that
you own.
Use the
--mspPath
flag to provide the path to the MSP of the token owner.export CONFIG_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/configorg1.json export MSP_PATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp . token list --config $CONFIG_FILE --mspPath $MSP_PATH --channel mychannel
If successful, the command will return the tokenID, which is the ID of the transaction that created the token, as well as the type and quantity of assets represented by the token.
{"tx_id":"23604056d205c656fa757f568a6a4f0105567ebc208303065aa7e5a11849c0c8"} [Fabcoins,100]
token transfer example¶
You can transfer the tokens that you own to another member of the channel using
the token transfer
command.
Use the
--tokenIDs
flag to select the tokens that you want to transfer. Use the--shares
flag to provide a path to a JSON file that describes how the input token will be distributed to the recipients of the transaction. You can find a sample shares file below.export CONFIG_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/configorg1.json export MSP_PATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp export SHARES=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/shares.json . token transfer --config $CONFIG_FILE --mspPath $MSP_PATH --channel mychannel --tokenIDs '[{"tx_id":"23604056d205c656fa757f568a6a4f0105567ebc208303065aa7e5a11849c0c8"}]' --shares $SHARES . 2019-03-28 18:27:43.468 UTC [token.client] BroadcastReceive -> INFO 001 calling OrdererClient.broadcastReceive Orderer Status [SUCCESS] Committed [true]
token redeem example¶
Redeemed tokens can no longer be transferred to other channel members. Tokens
can only be redeemed by their owner. You can use the following command to redeem
50 Fabcoins
:
```
export CONFIG_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/configorg1.json
export MSP_PATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp
.
token redeem --config $CONFIG_FILE --mspPath $MSP_PATH --channel mychannel --tokenIDs '[{"tx_id":"30e6337fdc0d07a5c46f51d6b58c4958992e21fed0aed5c822b30f9f28366698"}]' --quantity 50
.
2019-03-28 18:29:29.656 UTC [token.client] BroadcastReceive -> INFO 001 calling OrdererClient.broadcastReceive
Orderer Status [SUCCESS]
Committed [true]
```
Configuration file example¶
The configuration file provides the token CLI the endpoint information of your network. The file include the Prover Peer that your organization will use to assemble token transactions.