Chaincode is essentially the business logic governing how different entities in a blockchain network interact or transact with one another.
Understanding chaincode
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.
Chaincode terminology
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.
Consider the example of a business selling vehicles to another business.
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.
System chaincode
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.
Key takeaways:
Chaincode details the business logic governing the interaction of different entities on a blockchain network.
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.
Read Next: Proof-of-stake, Proof-of-work, Bitcoin, Ethereum, Blockchain.
Main Free Guides:
- Business Models
- Business Strategy
- Business Development
- Digital Business Models
- Distribution Channels
- Marketing Strategy
- Platform Business Models
- Revenue Models
- Tech Business Models
- Blockchain Business Models Framework
Related Blockchain Business Frameworks
Proof of Work vs. Proof of Stake
Blockchain Business Model Framework