Giter VIP home page Giter VIP logo

voting-v1's Introduction


VOTING CHAINCODE DEPLOY

Execute the following instructions serial.


Vagrant dev env

Instructions


First of all log in vagrant:

  • cd ~/go/src/github.com/hyperledger/fabric/devenv/
  • vagrant up
  • vagrant ssh

Download fabric-sample

  • Create a directory where you want to. mkdir fabric-sample
  • cd fabric-sample
  • Execute : curl -sSL https://goo.gl/LQkuoh | bash

Deploy

  • cd release/linux-amd64$

  • ./network_setup.sh down - needed in case it's not the first time deploying.

  • ./generateArtifacts.sh mychannel

  • vi docker_compose_cli.yaml - needed in case it's the first time deploying.

    And comment the following line: command: /bin/bash -c './scripts/script.sh ${CHANNEL_NAME}; sleep $TIMEOUT'. Your file should look like this:

     working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
     # command: /bin/bash -c './scripts/script.sh ${CHANNEL_NAME}; sleep $TIMEOUT'
     volumes
    
  • CHANNEL_NAME=mychannel TIMEOUT=3600 docker-compose -f docker-compose-cli.yaml up -d

  • docker exec -it cli bash

  • peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/cacerts/ca.example.com-cert.pem

  • peer channel join -b mychannel.block

  • go get github.com/giou-k/Voting

  • peer chaincode install -n mycc -v 1.0 -p github.com/giou-k/Voting

  • peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/cacerts/ca.example.com-cert.pem -C mychannel -n mycc -v 1.0 -p github.com/giou-k/Voting -c '{"Args":[]}' -P "OR ('Org1MSP.member','Org2MSP.member')"

  • After the instantiation you can see logs.


Logs

  • docker ps
  • docker logs -f <container id> . The <container id> will have as <image> yours chaincode name (ex: mycc) after the instantiation of the CC.

Test Init

  • peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/cacerts/ca.example.com-cert.pem -C mychannel -n mycc -c '{"Args":["init","314"]}'

Voter Invoke - Query -Delete

  • peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/cacerts/ca.example.com-cert.pem -C mychannel -n mycc -c '{"Args":["init_voter","v001","100"]}'

  • peer chaincode query -C mychannel -n mycc -c '{"Args":["read_voter","v001"]}'

  • peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/cacerts/ca.example.com-cert.pem -C mychannel -n mycc -c '{"Args":["delete_voter","v001"]}'


Candidate Invoke - Query - Delete

  • peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/cacerts/ca.example.com-cert.pem -C mychannel -n mycc -c '{"Args":["init_candidate","c001","christopher wallace"]}'

  • peer chaincode query -C mychannel -n mycc -c '{"Args":["read_candidate","c001"]}'

  • peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/cacerts/ca.example.com-cert.pem -C mychannel -n mycc -c '{"Args":["delete_candidate","c001"]}'


Transfer Vote

  • peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/cacerts/ca.example.com-cert.pem -C mychannel -n mycc -c '{"Args":["transfer_vote","v001","c001","20"]}'

voting-v1's People

Watchers

James Cloos avatar

Forkers

trellixvulnteam

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.