This is a stripped-down toy model that I have been playing with to learn more about hyperledger. This is based on the release-1.4
version of fabric-samples
The basic network consists of just one organisation, one orderer and one peer.
To start the network on the hypervault.tech server, run
sudo ./start.sh
in the basic-network
directory. This brings up the network that consists of the orderer and the peer. The script additionally initiates a channel called mychannel
, which stands for HyperVaultChannel, and joins the peer to the channel.
To install and instantiate the chaincode, we need to bring up the cli
container to act as the admin.
Run
sudo docker-compose -f docker-compose.yml up -d cli
to bring up the container and then go into the container by
sudo docker exec -it cli bash
Voila you are now in the cli
container, ready to take control of the network.
To check the channels that this entity is part of, simply run peer channel list
To install the chaincode, simply run in the cli
container
peer chaincode install -l node -n hypervault -v 0 -p /opt/gopath/src/github.com/hypervault/lowlevel
To verify that the chaincode has been successfully installed, run
peer chaincode list -C mychannel --installed
Finally, instantiate the chaincode by running
peer chaincode instantiate -n hypervault -v 0 -l node -C mychannel -c '{"Args":[]}'
The -c
flag is required even though we do not need any arguments in the Args
field.
Run in the cli
container
peer chaincode invoke -n hypervault -C mychannel -c '{"Function":"initLedger", "Args":[]}'
This initialises the ledger by calling the initLedger
chaincode function. Now let's check the results!
peer chaincode invoke -n hypervault -C mychannel -c '{"Function":"queryAllCars", "Args":[]}'
And you should see the result as
Chaincode invoke successful. result: status:200 payload:"[{\"Key\":\"CAR0\",\"Record\":{\"color\":\"Absolutely transparent\",\"docType\":\"car\",\"make\":\"HyperSecure\",\"model\":\"Super confidential\",\"owner\":\"HyperVault\"}}]"
Voila, hypervault 0.0
is now running!
After a bit of painful debugging, I have discovered that the chaincode file name must match the chaincode name, which should actually seem obvious.