0Pricing
Web3 & DApp Development Fundamentals · 课时

区块与链

了解区块如何连接

区块与链 是 CoddyKit 上的免费 Web3 & DApp Development Fundamentals 课时。 这是第 1 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Web3 & DApp Development Fundamentals 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Web3 & DApp Development Fundamentals 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

What Is a Block?

A block is the fundamental container in a blockchain. It bundles together a set of validated transactions along with metadata that ties it to the rest of the chain.

Each block has two main parts:

  • Header — metadata (timestamp, hashes, nonce)
  • Body — the list of transactions

Anatomy of a Block Header

The header is small but powerful. A typical Ethereum-style header includes:

  • previousHash — hash of the prior block
  • timestamp — when the block was created
  • merkleRoot — fingerprint of all transactions
  • nonce — value used in consensus

The header is what gets hashed to identify the block.

block Header {
    previousHash: 0x9f1c...a3
    timestamp:    1717000000
    merkleRoot:   0x4be2...07
    nonce:        42891
}

How Blocks Link Together

Every block stores the hash of the previous block. This single field is what turns a pile of blocks into a chain.

Because each block points backward, the blocks form an ordered, append-only sequence reaching all the way back to the very first block.

Block 0 (Genesis)
   |  hash = 0xAAA
   v
Block 1  prevHash = 0xAAA  hash = 0xBBB
   |
   v
Block 2  prevHash = 0xBBB  hash = 0xCCC

The Genesis Block

The genesis block is the first block in any blockchain. It is special because it has no parent — its previousHash is typically all zeros.

Every other block can be traced back to genesis, which acts as the shared root of trust for the entire network.

Genesis = {
    previousHash: 0x0000000000000000
    timestamp:    1438269973
    transactions: []
}

Why the Backward Link Matters

The backward link makes tampering obvious. If someone alters a transaction in an old block, that block's hash changes.

But the next block stored the old hash in its previousHash field, so the link breaks. The mismatch is instantly detectable.

Chains Are Append-Only

Blockchains are append-only data structures. You can add new blocks to the tip, but you cannot insert or delete blocks in the middle without breaking every link that follows.

This property is the foundation of blockchain immutability.

Block Height

Block height is the number of blocks between a given block and the genesis block. Genesis is height 0, the next block is height 1, and so on.

Height gives every block a clear position and lets the network agree on which chain is longest.

height 0 -> Genesis
height 1 -> Block 1
height 2 -> Block 2
...
height N -> latest block

Transactions Inside a Block

The block body holds an ordered list of transactions. Order matters: it determines the final state after the block is applied.

Once a block is finalized, the transactions it contains — and their order — are fixed forever.

Block 12 body:
  tx[0]: Alice -> Bob   (5 ETH)
  tx[1]: Bob   -> Carol (2 ETH)
  tx[2]: Carol -> Dave  (1 ETH)

Block Size and Limits

Blocks cannot grow without limit. Each chain sets a cap — Bitcoin uses a byte limit, while Ethereum caps the total gas a block may consume.

These limits keep blocks small enough to propagate quickly across the network.

Identifying a Block by Its Hash

A block's identity is its hash — the output of running its header through a cryptographic hash function.

Change any field in the header and the hash changes completely. That is why hashes act as tamper-evident fingerprints for blocks.

blockHash = sha256(
    previousHash + timestamp +
    merkleRoot + nonce
)

Putting It Together

A blockchain is simply a linked list of blocks where each link is a cryptographic hash of the prior block.

This combination of ordering, hashing, and append-only writes is what makes the chain trustworthy without any central authority.

Quick Check

Test your understanding of how blocks connect.

Recap: Blocks and Chains

You learned that:

  • A block has a header (metadata) and a body (transactions)
  • Blocks link by storing the previousHash
  • The genesis block is the root with no parent
  • Chains are append-only, making them immutable
  • A block's identity is its hash

Next, we explore how Merkle Trees summarize all transactions efficiently.

常见问题解答

「区块与链」课时是免费的吗?

是的 — 「区块与链」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Web3 & DApp Development Fundamentals 课程的其余内容,请升级到 CoddyKit PRO。 Web3 & DApp Development Fundamentals 课程共包含 4 节课。

「区块与链」这节课中我会学到什么?

了解区块如何连接 你通过在浏览器中直接运行的动手代码来练习 Web3 & DApp Development Fundamentals,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 Web3 & DApp Development Fundamentals 需要有经验吗?

无需任何先前经验。CoddyKit 上的 Web3 & DApp Development Fundamentals 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 1 节课,共 4 节。

「区块与链」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 Web3 & DApp Development Fundamentals 课中编写并运行代码吗?

能。每节 Web3 & DApp Development Fundamentals 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 区块与链
  2. 默克尔树
  3. 区块链中的哈希
  4. 分布式账本
← 返回 Web3 & DApp Development Fundamentals