Skip to content

ALT-F1/chaincode-helloworld

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chain code - Hello world using go and the hyperledger

How to Use

  1. Go-Install Go language
  2. Clone the hyperledger
  3. Fabric-Install the fabric
  4. Fabric-Setup the development environment
  5. Look at the credentials of Lukas inside the membersrvc.yaml, the user will have to log on to interact with the hyperledger
  6. Clone this code Chaincode-Helloworld into <hyperledger directory>/fabric/examples
  7. Setup 3 UNSECURED peers (setting up secured peers generate marshalling errors for the moment)
    1. Setup 3 terminals as described in Writing Building and Running Chaincode in a Development Environment
    2. Security Setup
      1. Start your favorite bash command line, on windows start Git bash for example
      2. cd <GO PATH>/gopg/src/github.com/hyperledger/fabric/devenv/
      3. vagrant up
      4. vagrant ssh
      5. cd $GOPATH/src/github.com/hyperledger/fabric/
      6. make membersrvc && membersrvc
    3. Vagrant Terminal 1 (validating peer)
      1. Start your favorite bash command line, on windows start Git bash for example
      2. cd <GO PATH>/gopg/src/github.com/hyperledger/fabric/devenv/
      3. vagrant ssh
      4. cd $GOPATH/src/github.com/hyperledger/fabric/
      5. make peer
      6. peer node start --peer-chaincodedev
    4. Vagrant Terminal 2 (chaincode)
      1. Start your favorite bash command line, on windows start Git bash for example
      2. cd <GO PATH>/gopg/src/github.com/hyperledger/fabric/devenv/
      3. vagrant ssh
      4. cd $GOPATH/src/github.com/hyperledger/fabric/examples/chaincode/go/altf1be/chaincode-helloworld/helloworld
      5. go build && CORE_CHAINCODE_ID_NAME=helloWorld CORE_PEER_ADDRESS=0.0.0.0:30303 ./helloworld
    5. Vagrant Terminal 3 (Command line interpreter)
      1. Start your favorite bash command line, on windows start Git bash for example
      2. cd <GO PATH>/gopg/src/github.com/hyperledger/fabric/devenv/
      3. vagrant ssh
      4. $GOPATH/src/github.com/hyperledger/fabric/peer
      5. peer network login lukas
        1. input the password stored in membersrvc.yaml
      6. deploy the chaincode-helloword peer chaincode deploy -p ./helloWorld -c '{"Function":"init", "Args":["noArgsyet"]}' -u lukas
      7. query the chaincode-helloword: peer chaincode query -u lukas -l golang -n helloWorld -c '{"Function": "query", "Args": ["b"]}'
      8. peer chaincode invoke -l golang -u lukas -n helloWorld -c '{"Function":"invoke", "Args":["noArgsyet"]}'

Vagrant Terminal 3 (Command line interpreter) - UNSECURED peers (working)

go build && CORE_CHAINCODE_ID_NAME=helloWorld CORE_PEER_ADDRESS=0.0.0.0:30303 ./helloworld

peer network login lukas

peer chaincode deploy -n helloWorld -c '{"Function":"init", "Args":["noArgsyet"]}'

peer chaincode invoke -l golang -n helloWorld -c '{"Function":"invoke", "Args":["noArgsyet"]}'

peer chaincode query -l golang -n helloWorld -c '{"Function": "quey", "Args": ["b"]}'

Vagrant Terminal 3 (Command line interpreter) - SECURED peers (does not work yet)

CORE_SECURITY_ENABLED=true CORE_SECURITY_PRIVACY=true peer chaincode deploy -p ./helloWorld -c '{"Function":"init", "Args":["noArgsyet"]}' -u lukas

CORE_SECURITY_ENABLED=true CORE_SECURITY_PRIVACY=true peer chaincode query -u lukas -l golang -n helloWorld -c '{"Function": "query", "Args": ["b"]}'

CORE_SECURITY_ENABLED=true CORE_SECURITY_PRIVACY=true peer chaincode invoke -l golang -u lukas -n helloWorld -c '{"Function":"invoke", "Args":["noArgsyet"]}'

CORE_SECURITY_ENABLED=true CORE_SECURITY_PRIVACY=true peer chaincode query -l golang -u lukas -n helloWorld -c '{"Function":"query", "Args":["noArgsyet"]}'

Theory - books

-- End of the Document

About

Chaincode HelloWorld using Go and Hyperledger

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages