ERC20 Token CLI Commands on TheSpiderman (SPDR)

SPDR Admin
·Jan 17, 2022·

2 min read

ERC20 Token CLI Commands on TheSpiderman (SPDR)

peer chaincode invoke -o orderer.spdr.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/spdr.com/orderers/orderer.spdr.com/msp/tlscacerts/tlsca.spdr.com-cert.pem -C mychannel -n mycc --peerAddresses peer0.org1.spdr.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.spdr.com/peers/peer0.org1.spdr.com/tls/ca.crt --peerAddresses peer0.org2.spdr.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.spdr.com/peers/peer0.org2.spdr.com/tls/ca.crt -c '{"Args":["mint","Org1MSP", "5100.2345"]}'
2022-01-16 09:46:14.283 UTC [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2022-01-16 09:46:14.289 UTC [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2022-01-16 09:46:14.330 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 003 Chaincode invoke successful. result: status:200 

root@6183bccd4bc6:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C mychannel -n mycc -c '{"Args":["getBalanceOf", "Org1MSP"]}'
2022-01-16 09:46:26.212 UTC [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2022-01-16 09:46:26.218 UTC [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
5100.2345

root@6183bccd4bc6:/opt/gopath/src/github.com/hyperledger/fabric/peer#

Here 5100.2345 tokens are minted, see the screenshot below:

token1.png

Now, we will transfer 100 tokens between peers

peer chaincode invoke -o orderer.spdr.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/spdr.com/orderers/orderer.spdr.com/msp/tlscacerts/tlsca.spdr.com-cert.pem -C mychannel -n mycc --peerAddresses peer0.org1.spdr.com:7051 --tlsRootCertFiles 

/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.spdr.com/peers/peer0.org1.spdr.com/tls/ca.crt --peerAddresses peer0.org2.spdr.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.spdr.com/peers/peer0.org2.spdr.com/tls/ca.crt -c '{"Args":["transfer","Org2MSP", "100"]}'

As you can see, with above CLI command, 100 tokens are to peer0.org2.spdr.com

token2.png

And in the next example, we get the name of the TOKEN

token3.png

We have named it SPDR COIN.

Next we get the balance of the Tokens:

token4.png

Example - getBalanceOf() function shows that we started with 5100.XXX, transfer 100 to ORG2

TheSpiderman (SPDR) will provide a simple API to use from your environment or from the UI.

 
Share this