From the point of view of an app developer, a smart contract and a ledger are central to the Hyperledger Fabric blockchain framework.
Here, the ledger stores facts about the current and historical states of a set of business objects. Smart contracts define the executable logic that generates new facts which are added to the ledger.
Administrators use chaincode to group related smart contracts for deployment. Chaincode can also be used for low-level system programming of Fabric and is typically written in Go, node.js, or Java.
In the context of Hyperledger Fabric, many use the terms smart contract and chaincode interchangeably.
Generally speaking, however, a smart contract defines the transaction logic that in turn controls the lifecycle of a business object. This contract is then packaged into a chaincode and deployed to a blockchain network.
To make the distinction between the two terms, it is useful to think of smart contracts as governing transactions and chaincode as something which determines how those contracts are packaged for deployment.
Smart contracts lay out an agreed process to transfer the ownership of each vehicle from one business to the other. A vehicle chaincode may contain smart contracts for cars, trucks, boats, and buses.
There may also be an insurance chaincode, which contains further smart contracts for policy, insurance, and vehicle registration. To reiterate a point made earlier, remember that chaincode is a technical container of a group of related smart contracts. The smart contracts themselves are simply domain-specific programs relating to specific business processes – such as selling a type of vehicle.
Chaincode can also define low-level program code corresponding to independent system interactions. This process is unrelated to its ability to define smart contracts.
Here is a look at some common system chaincodes:
- Query system chaincode (QSCC) – which runs in all peers to provide ledger APIs such as block query and transaction query.
- Validation system chaincode (VSCC) – this chaincode validates a transaction by verifying endorsement policy and read-write set versioning.
- Configuration system chaincode (CSCC) – or code that runs across every peer to handle channel configuration changes such as policy updates. Channels are private communication pathways between two or more members on a Hyperledger Fabric blockchain network. Each channel has its own transaction ledger and each specifies which members can participate in the channel and the peer nodes that can transact.
- Endorsement system chaincode (ESCC) – this facilitates the endorsing and cryptographic signing of transaction proposals by relevant peers.
Chaincode is sometimes called smart contracts on the Hyperledger Fabric network. However, the two terms are more distinct. Chaincode determines how smart contracts are packaged for deployment.
Chaincode can also be used in low-level programming to define system interactions. These interactions include query, validation, configuration, and endorsement system chaincode.
Main Free Guides: