- Download and install Docker: https://www.docker.com/products/docker#/mac (or
brew install docker
) - Download and install Go: https://golang.org/doc/install (or
brew install golang
) - Download and install Node.js: https://nodejs.org/en/download/
- Create a directory to act as your Go workspace. Suggestion:
~/dev/go
. - In your Go workspace
mkdir -p src/github.com/
- In
.../go/src/github.com
add the hyperledger Go code:
mkdir hyperledger
cd hyperledger
git clone git@github.com:hyperledger/fabric.git
cd fabric
git fetch
git checkout v0.6
- In your
~/.zshrc
file addexport GOPATH=$HOME/dev/go
or whatever that path is.
In your dev directory. Assumed for this guide: ~/dev
git clone git@github.com:DecodedCo/blockchain-vote.git
cd blockchain-vote
Make sure you have Docker running on your mac, then:
cd ~/dev/blockchain-vote/docker-compose
docker pull hyperledger/fabric-peer:latest
docker pull hyperledger/fabric-membersrvc:latest
Wait a few moments then
cd one-peer-one-ca
docker-compose up
Open up a new shell, then:
cd ~/dev/blockchain-vote/golang-chaincode
go build .
Wait a moment then:
CORE_CHAINCODE_ID_NAME=DecodedBlockChain CORE_PEER_ADDRESS=0.0.0.0:7051 ./golang-chaincode
Open up another new shell, then:
cd ~/dev/blockchain-vote/node-server
npm install
npm start
Open a web browser and navigate to localhost:3000
Open up a fourth shell, then:
cd ~/dev/blockchain-vote/docker-compose/one-peer-one-ca
docker-compose stop
That stops the process and preserves the state of the blockchain. To delete the blockchain, run:
docker rm -f $(docker ps -aq)
The Go chaincode should stop running when the docker container stops. If not, the Go and Node processes can be stopped using ctrl+C