Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Blockchain in healthcare, retail, IoT and energy

Practical study notes on how blockchain is applied in healthcare, retail, IoT and energy, covering key concepts, design patterns, formulas, worked examples and exam pointers for engineering students.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Blockchain is used by engineers to build tamper-evident records, automated settlements, and decentralised access control across domains. In healthcare, retail, IoT and energy it helps with data integrity, auditability, and automated business logic (via smart contracts) while changing system architecture and trust models.

Key ideas

  • Smart contract — a program that runs on-chain and executes deterministic logic when triggered by transactions. Define clearly: has code, state, executes under the blockchain’s execution model (e.g., Ethereum Virtual Machine) and may cost gas or fees.

  • Permissioned vs Permissionless blockchains — permissionless allows any node to join and participate (e.g., public cryptocurrencies); permissioned requires identity/permission to join and is common in healthcare/enterprise settings. State differences: governance, privacy options, consensus choices.

  • Off-chain vs On-chain — on-chain data or logic is stored/executed on the blockchain; off-chain keeps large or sensitive data outside and stores only a reference (usually a hash) on-chain. For healthcare, always recommend off-chain for raw medical records and on-chain for hashes/consent metadata.

  • Merkle tree — a binary tree where leaves are transaction hashes and internal nodes are hashes of child concatenations. Define root and show how Merkle proofs demonstrate inclusion with O(log n) hashes. Diagram to draw (exam): draw a binary tree of four leaves T1..T4, show leaf hashes H1..H4, then H12 = H(H1||H2), H34 = H(H3||H4), root = H(H12||H34). Label each hash.

  • Throughput, latency, and finality — throughput (transactions per second, TPS) depends on block size and block time; latency is time to include a tx in a block and for the network to propagate it; finality is the assurance a block will not be reversed — in PoW this is probabilistic, in some permissioned consensus it can be deterministic.

  • Tokenization and settlement — in retail/energy, physical assets or energy units are represented by tokens. Define tokenization as mapping real-world asset state to a digital token and settlement as updating ledger state to transfer token ownership.

  • Oracles — components that bring real-world data (price, sensor reading) to the blockchain. Define trusted vs decentralized oracles and list the risk: oracle is a new trust boundary.

  • Domain-specific patterns

    • Healthcare: use-case pattern = off-chain EHR storage + on-chain access log and consent smart contracts + patient or provider identity (permissioned). Mention encryption at rest (patient-controlled keys) and audit trails on-chain.
    • Retail (supply chain): pattern = asset token lifecycle on-chain (CREATE → TRANSFER → INSPECT → SELL) + IoT sensors writing signed events. Use Merkle roots for shipping batches to compress many events.
    • IoT: resource-constrained device pattern = devices do local signing and send statements to gateway which aggregates and submits transactions; otherwise devices store only hashes. Define edge gateway role.
    • Energy (microgrids, P2P trading): pattern = local measurement by smart meters → signed meter readings → periodic settlement via smart contracts (tokens represent kWh) or batch settlement off-chain then final on-chain anchoring.
  • Security and privacy trade-offs: storing raw personal data on-chain breaks privacy and may violate law; encryption is necessary but key management is hard. Mention reference topics: Digital signatures, Merkle trees, Symmetric/asymmetric crypto.

  • Diagrams to draw in answers: (1) Block diagram showing Block(n) → Block(n-1) with arrows labelled hash pointer (previous_hash points to the prior block); inside a block draw header fields: previous_hash, merkle_root, timestamp, nonce; (2) Data flow for healthcare: Patient EHR (off-chain) — hash → blockchain; smart contract granting access — record events.

Formulas

Throughput (TPS) = (Block size in bytes / Avg tx size in bytes) / Block time in seconds — Block size and tx size in bytes; TPS in transactions per second; applies when all block space used and tx sizes are uniform.

Energy (J) = Power (W) × Time (s) — Energy in joules; power in watts; time in seconds. Use E = P·t to compute device energy consumption.

Energy (kWh) = Power (W) × Time (h) / 1000 — energy in kilowatt-hours, commonly used for billing.

Cost = Energy (kWh) × Price (currency per kWh) — monetary cost of energy used.

Latency_total (avg) ≈ 0.5 × Block time + Network propagation delay + Confirmation wait — latency in seconds (average-case); confirmation wait depends on required finality depth (e.g., number of block confirmations).

Batching factor = N_offchain / N_onchain — conceptual: how many raw events are compressed into a single on-chain transaction using aggregation (N_onchain < N_offchain).

Worked examples

  1. Throughput calculation (blockchain node parameters) Given: block size = 1 MB (1,048,576 bytes), average transaction size = 500 bytes, block time = 10 s. Formula: Throughput (TPS) = (Block size / Avg tx size) / Block time. Calculation: Block size / Avg tx size = 1,048,576 / 500 = 2,097.152 transactions per block. TPS = 2,097.152 / 10 = 209.7152 TPS. Answer: ≈ 210 TPS. Notes: This is an upper bound — real TPS lower because of propagation, block header overhead and variable tx sizes.

  2. Energy node cost example (edge gateway that posts meter data) Given: gateway average power draw P = 5 W, runs 24 h/day. Electricity price = 8 ₹/kWh. Formula: Energy (kWh/day) = P (W) × Time (h) / 1000. Calculation: E = 5 × 24 / 1000 = 0.12 kWh/day. Cost per day = 0.12 × 8 = 0.96 ₹/day. Weekly cost = 0.96 × 7 = 6.72 ₹. Answer: 0.12 kWh/day, costing 0.96 ₹/day. Note: check actual device power and local tariff for accurate cost (see verify list).

  3. Retail supply-chain smart-contract trace (algorithmic answer) Task: trace a product token through three transactions. Inputs: product P1, Manufacturer M, Distributor D, Retailer R. Smart contract supports events CREATE(id,supplier), TRANSFER(id,from,to), RECEIVE(id,to). Steps:

  1. M calls CREATE(P1,M). Contract stores state: owner[P1] = M, status[P1] = "Created". Emit event Created(P1,M).
  2. M calls TRANSFER(P1,M,D). Contract checks owner[P1]==M, then owner[P1]=D, status="InTransit". Emit Transfer(P1,M,D).
  3. D calls RECEIVE(P1,D). Contract checks owner[P1]==D, status="InTransit", then status="Received". Emit Received(P1,D). At each step, transactions are signed by the sender with their private key (see Digital signatures). To show faults in an exam, describe how a malicious node could replay an old TRANSFER; prevent by sequence numbers or nonces on tokens. Answer: provide state table after each step (show owner and status) — this is expected in full-marks answer.
  1. Model answer (short essay) — Blockchain design for patient consent and record access Structure an answer in sections: goals, actors, data flow, privacy, security, and trade-offs. Example solution: store full EHR in hospital cloud encrypted; patient holds key or uses threshold key share; on-chain store consent records and hashes (not raw data); smart contract enforces consent granting/revocation and logs access events; use permissioned blockchain to keep participants known (hospitals, labs, insurers); use off-chain identity provider or DID for mapping. Discuss pros: auditability, fine-grained consent; cons: key loss risk, oracle/trust issues, scaling. Conclude with real-world constraints (laws, latency) and mention to check specific legal requirements.

Common mistakes

  • Forgetting to mention oracles when on-chain logic needs external data (prices, sensor values).
  • Ignoring key management: many designs assume users keep private keys safely — exam answers must state key recovery or custody choices.
  • Using throughput formula without accounting for header/metadata and propagation delays — always state assumptions.
  • Assuming PoW finality is instant — must explain probabilistic finality and required confirmations.

For your exam

Question types you will see: definitions (e.g., define tokenization), short notes (patterns for healthcare or microgrids), derivations/calculations (TPS, energy cost), algorithm traces (smart-contract state transitions), and system-design essays (design a privacy-preserving patient data sharing system). Full-marks answers must:

  • State definitions precisely and bold any terms when listing in an answer (if asked).
  • Show assumptions (network model, block time, sizes) before calculations.
  • For designs, give clear actor lists, data flows, trust boundaries, and mention cryptography used (hashes, signatures) and where to keep sensitive data (off-chain).
  • Include diagrams described in words if drawing is required (labelled blocks, merkle tree, flow arrows).

Quick check

  1. Why should raw medical records usually be kept off-chain?
  2. What is an oracle in blockchain systems?
  3. If block time = 5 s, block size = 500 kB and avg tx = 250 bytes, roughly what TPS upper bound do you get?
    Answers: Off-chain avoids permanent public exposure and privacy/legal issues; an oracle brings external real-world data into the blockchain; TPS ≈ (500,000/250)/5 ≈ (2000)/5 = 400 TPS.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?