Intro to Hyperledger
In this module, we'll explore where Hyperledger came from, and how it has evolved over time.
The best way to understand how Hyperledger works is to set up your own node.
Example: Hyperledger for Car Dealerships
It's not the size of your node that matters - it's how you use it.
Before we move on to interactions with the ledger, it will help to review how the ledger is updated in Query.js. ( see fabric-samples/fabcar/query.js)
Connecting to the Peer SDK
In the first four lines of this script, we’ll introduce our libraries:
Then, we can initialize the Hyperledger client and connect to the network:
Querying the ledger
When a client queries a Hyperledger node, the state object is returned as the consensus at that time. In section 1 we covered the transaction flow in greater detail, but we’ll now see how the query object is generated and passed to the network endpoint / SDK.
The first 50 lines or so of query.js handle connecting to the network and authenticating the user that we created in the previous step. Finally, we can prepare a test query on line 54:
You can send the query by triggering the script using the following command:
If your Hyperledger node is running this should return a printout of json data, but right now it will be empty because we haven’t added any cars to the dealership’s registry!
In the next section, we’ll explore the chaincode and see how this payload gets processed by other nodes on the network!