New to Rust? Grab our free Rust for Beginners eBook Get it free →
Introduction to Blockchain: Blocks, Hashes, and Consensus

Blockchain is a shared record that a network maintains without giving one machine the only copy. The useful beginner question is how a network can accept a new record and make later edits visible. That mechanism combines blocks, hashes, and a consensus rule.
What blockchain is
A blockchain is a ledger made of ordered blocks. Each block records data and includes a cryptographic hash that identifies its contents, plus a reference to the previous block.
The Bitcoin developer guide describes the link directly: a block header stores the previous block header’s hash, and its Merkle root summarizes the block’s transactions. Changing a transaction changes that summary, which changes the block hash and breaks the link that the next block expects.
A hash is a tamper signal, not a lock
A hash function turns input data into a fixed-length value, and the same input produces the same hash while a changed input produces a different hash with overwhelming probability.
That property makes edits detectable. It does not stop someone from changing data and calculating replacement hashes, so a blockchain also needs other nodes to reject a history that violates the network’s consensus rules.
How a blockchain adds a record
Network details vary, yet a participant broadcasts a transaction or state change, nodes validate it, a block producer proposes a block, and the network applies its consensus rules before treating that block as part of the ledger.
- A transaction states a requested change, such as moving an asset or calling a smart contract.
- Nodes check the transaction against the protocol rules, including signatures and available funds when the network tracks balances.
- A proposed block groups valid transactions and references the previous accepted block.
- Consensus determines whether nodes accept the proposal and which chain they follow when competing proposals appear.
Consensus is the part that lets independent machines converge on one accepted history. It is not encryption, and it does not mean every network uses the same security model.
Proof of work and proof of stake solve different network choices
Bitcoin uses proof of work, where miners spend computational effort to propose blocks, and Ethereum uses proof of stake, where validators stake ETH and participate in checking and proposing blocks under its protocol rules.
Both approaches make dishonest behavior expensive in different ways. A hash chain shows whether data changed, while consensus decides which valid-looking history the network accepts.
Build a tiny hash-linked chain in Node.js
The following example uses Node’s built-in crypto module with no package dependency and models hash linking only, excluding mining, validator selection, peer-to-peer networking, wallets, and a production ledger.
const crypto = require('node:crypto');
function digest(value) {
return crypto.createHash('sha256').update(value).digest('hex');
}
function makeBlock(index, previousHash, data) {
const timestamp = '2026-08-17T00:00:00.000Z';
const hash = digest(`${index}|${previousHash}|${timestamp}|${JSON.stringify(data)}`);
return { index, previousHash, timestamp, data, hash };
}
function verifyChain(chain) {
for (let index = 1; index < chain.length; index += 1) {
const block = chain[index];
const expectedHash = digest(
`${block.index}|${block.previousHash}|${block.timestamp}|${JSON.stringify(block.data)}`,
);
if (block.previousHash !== chain[index - 1].hash || block.hash !== expectedHash) {
return false;
}
}
return true;
}
const genesis = makeBlock(0, '0', { message: 'genesis' });
const payment = makeBlock(1, genesis.hash, { from: 'Ava', to: 'Noah', amount: 7 });
const chain = [genesis, payment];
console.log('valid before change:', verifyChain(chain));
chain[1].data.amount = 70;
console.log('valid after change:', verifyChain(chain));
console.log('stored previous hash:', chain[1].previousHash.slice(0, 16));
console.log('recomputed block hash:', digest(`${chain[1].index}|${chain[1].previousHash}|${chain[1].timestamp}|${JSON.stringify(chain[1].data)}`).slice(0, 16));
Save the file as hash-chain-demo.js. From that directory, run the command below.
cd ~/blockchain-demo && node hash-chain-demo.js
The first check returns true because the stored hash matches the block data. After the amount changes, the recomputed hash differs from the stored hash, so verifyChain() returns false.

The fixed timestamp keeps the output repeatable, and production blockchains use protocol-defined fields and calculate hashes over a precise binary serialization instead of a JavaScript object string.
Public, private, and consortium networks
Network access determines who can read, submit, validate, or administer records. Those choices matter more than the word blockchain when you are deciding whether a system fits a use case.
| Network type | Who participates | Common use |
|---|---|---|
| Public and permissionless | Anyone can typically inspect the ledger and join under the protocol’s rules. | Cryptocurrency networks and public applications. |
| Private and permissioned | An organization controls membership and permissions. | Internal workflows with identified participants. |
| Consortium | Several known organizations share governance. | Cross-company workflows where members need a shared record. |
Hyperledger Fabric documents permissioned networks as groups of known and identified participants operating under governance rules, and a permissioned ledger has different trust assumptions from a public network such as Bitcoin.
What a blockchain cannot guarantee
A blockchain can preserve evidence of what its network accepted, yet it cannot prove that an external claim was correct when someone entered it, recover a lost private key, or make a poor smart contract safe.
Public transaction history can also create privacy concerns because addresses and transfers may remain observable. Before designing a blockchain system, define who needs to trust whom, what needs shared verification, and whether an ordinary database with access controls already satisfies the requirement.
Where to go next
Read the Bitcoin block chain developer guide to inspect block headers and Merkle trees, then compare Ethereum’s proof-of-stake documentation with the small hash-chain example. The next useful question is how a network validates transactions before a block is accepted.
Is blockchain the same as Bitcoin?
No. Bitcoin is a public blockchain network and cryptocurrency. Blockchain describes a way to organize and replicate a ledger across participants, and other networks use different protocols and purposes.
Can blockchain data be changed?
A participant can alter a local copy, but the altered block no longer matches the hashes and consensus history that other nodes accept. The practical difficulty of changing accepted history depends on the network and its consensus design.
Do all blockchains use proof of work?
No. Bitcoin uses proof of work, while Ethereum uses proof of stake. Permissioned networks can use other validation and governance arrangements.




