The chaincode is made with hyperledger fabric. It is used to store the data of the logbook entries. It is written in typescript in Node.js and compiled to javascript.
If you decide to host your own chaincode, you need to have a running instance of hyperledger fabric. You can find more information on how to do this in the hyperledger fabric documentation.
The REST API can send logs to a Discord channel. To do this, you need to create a Discord Webhook and change the Discord webhook url url
in the DiscordHook file.
Locate into the chaincode directory:
cd chaincode
Build the docker image:
docker build -t scrayorg/logbook-app-chaincode:1.0 .
Run the docker image:
docker run scrayorg/logbook-app-chaincode:1.0
You will have to open some ports to be able to communicate with the chaincode.
docker save scrayorg/logbook-app-chaincode:1.0 > logbook-app-chaincode:1.0.tar
microk8s ctr image import logbook-app-chaincode:1.0.tar
PKGID=basic_1.0:a50b6e6de3ac0a753193c6f36767ca26f2a09670542ed6a5ded0b1ac3efef923
kubectl delete configmap invoice-chaincode-external
kubectl create configmap invoice-chaincode-external \
--from-literal=chaincode_id=$PKGID
kubectl apply -f k8s-deployment-descriptor.yaml
- Get pod with contains the chaincode:
CC_POD=$(kubectl get pod -l app=logbook-app-chaincode -o jsonpath="{.items[0].metadata.name}")
- Get console promt in chain code container
kubectl exec --stdin --tty $CC_POD -- /bin/sh
- Edit chain code
cd /usr/local/lib/logbook-app/chaincode vi release/blockchain/contract.js
- Compiel and start chain code
npm install npm start
nohup npm start > /var/log/chaincode/logbook-app.logs 2>&1 &
kill $(ps -ef | pgrep -f fabric-chaincode-node)
tail -f /var/log/chaincode/logbook-app.logs
peer chaincode query -C channel-1 -n basic -c '{"function":"getTours","Args":[""]}'