Chaincode

Chaincode is the term used in Hyperledger Fabric to refer to the business logic or smart contracts that run on a blockchain network. It defines the rules and data structures for transactions, enabling the manipulation of ledger state.

Architecture & Execution

  • Runs in isolated execution environments (e.g., docker containers or WebAssembly modules).
  • Invoked by Transactions via a Proposal flow: clients submit proposals to endorsing peers, which simulate the chaincode to read/write sets without committing to the ledger.
  • Supports multiple languages, primarily Go, nodejs, and Java.

Key Characteristics

  • State Management: Maintains a key-value store for the specific chaincode instance.
  • Isolation: Each chaincode instance operates in its own namespace to prevent conflicts.
  • Lifecycle: Managed through a lifecycle protocol (package, approve, commit) distinct from the underlying peer infrastructure.

Applications in Healthcare

  • Smart Contract
  • Endorsement Policy
  • World State
  • Hyperledger Fabric