liveBook · Manning

Block

As explained in The Joy of JavaScript

A block is a fixed unit of data in a blockchain that groups transactions and metadata for chaining to prior blocks.

A block is an immutable unit of blockchain data. It groups transactions or other data with metadata, then links to earlier blocks through a previous hash rather than an ordinary pointer. section 1.6

A JavaScript Block model typically carries:

  • An index, timestamp, transaction data, previousHash, and its calculated hash. section 3.5
  • A genesis check that recognizes the first block through a repeated-zero previous hash. section 3.5
  • Hashing and validation behavior supplied through reusable mixins. section 3.5
  • A tamper-evident chain: changing one block requires recomputing its hash and affects the hashes that follow. section 1.6 section 3.5

A block carrying transactions

A payment begins as a pending transaction. After validation, it joins other transactions in a new block, which is appended to the chain and makes the payment complete. section 1.6

Controlled JSON representation

A Block can expose a Symbol.for('toJson') method that serializes its index, previousHash, hash, timestamp, data count, data, and version. A ledger can then serialize each block and combine the results into a buffer. section 7.4.3

Figure 1.13 A simple representation of a blockchain, in which each block stores the previous block’s hash. This hash is used to compute the current block’s own hash, effectively connecting all these blocks in a chain.

Shows how each block stores the previous block’s hash, allowing the current hash to connect the chain. section 1.6

How The Joy of JavaScript covers it

How deep it goes
Defines fields, genesis detection, hashing, validation, tamper detection, and custom serialization, while keeping cryptography pedagogical.
Examples
Uses payment aggregation, a JavaScript Block class, reusable hash and validation mixins, and symbol-based JSON serialization.
What it assumes
Assumes JavaScript background while requiring no prior blockchain knowledge.
What you can do after
Build it from scratch as a small JavaScript blockchain model with transaction storage, hash linkage, validation, and serialization.
How it connects
Connects blockchain, transactions, hashing, genesis blocks, immutability, mixins, validation, and serialization.

Also explained in

Compare how 2 books explain block →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Joy of JavaScript. The section links point to the parts of the book it draws on.