Coder Social home page Coder Social logo

chaincode-helloworld's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.