Web3 & DApp Development Fundamentals · 강의

머클 트리

효율적인 검증

레슨 2/413개 단계

머클 트리은(는) CoddyKit의 무료 Web3 & DApp Development Fundamentals 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Web3 & DApp Development Fundamentals 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Web3 & DApp Development Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

The Problem Merkle Trees Solve

A block may contain thousands of transactions. How can a lightweight device verify that one specific transaction is included without downloading them all?

The answer is the Merkle tree — a structure that lets you prove membership with just a handful of hashes.

What Is a Merkle Tree?

A Merkle tree (or hash tree) is a binary tree where:

  • Each leaf is the hash of one transaction
  • Each internal node is the hash of its two children combined
  • The single top node is the Merkle root

Building the Tree

Construction works bottom-up. Hash each transaction to form the leaves, then repeatedly hash pairs together until only one hash remains.

Leaves:  H(tx1) H(tx2) H(tx3) H(tx4)
Level 1: H(H(tx1)+H(tx2))  H(H(tx3)+H(tx4))
Root:    H(level1a + level1b)

The Merkle Root

The Merkle root is a single hash that represents every transaction in the block. It is stored in the block header.

If even one transaction changes, the root changes — so the root acts as a compact fingerprint of the entire transaction set.

Handling an Odd Number of Leaves

If a level has an odd number of nodes, the last node is usually duplicated so it can be paired.

This keeps the tree balanced and ensures every node has a sibling to hash with.

Leaves: H(tx1) H(tx2) H(tx3)
-> duplicate last: H(tx3) H(tx3)
Level 1: H(tx1+tx2)  H(tx3+tx3)

Merkle Proofs

A Merkle proof is the small set of sibling hashes needed to recompute the root from a single leaf.

To prove tx2 is included, you only need the siblings along its path — not the other transactions themselves.

Prove tx2 is in the block:
  provide H(tx1) and H(tx3+tx4)
  recompute: H( H(tx1)+H(tx2) )
  then:      H( that + H(tx3+tx4) )
  compare to stored Merkle root

Why Proofs Are Efficient

For N transactions, a Merkle proof needs only about log2(N) hashes.

For one million transactions, that is roughly 20 hashes instead of a million — a massive saving for light clients and mobile wallets.

Light Clients (SPV)

Simplified Payment Verification clients download only block headers, not full blocks.

Using a Merkle proof from a full node, an SPV client can confirm a transaction is in a block without trusting that node blindly.

Tamper Detection

Because every transaction feeds into the Merkle root, altering any transaction produces a different root.

The header's root would no longer match the recomputed root, so the tampering is immediately exposed.

Merkle Trees Beyond Transactions

Merkle trees are used far beyond transaction lists. Ethereum uses a variant called a Merkle Patricia Trie to commit to the entire world state and to receipts.

Git, IPFS, and many databases also rely on Merkle structures for integrity.

Putting It Together

The Merkle tree turns a large set of transactions into a single root hash while still allowing compact, verifiable membership proofs.

It is one of the most elegant data structures behind scalable, trustless verification.

Quick Check

Check your grasp of Merkle proofs.

Recap: Merkle Trees

You learned that:

  • A Merkle tree hashes transactions in pairs up to a single root
  • The Merkle root is a fingerprint stored in the header
  • A Merkle proof needs only ~log2(N) hashes
  • This enables efficient light clients and tamper detection

Next we dig into the hashing that powers all of this.

무료로 시작

AI 튜터와 함께 Web3 & DApp Development Fundamentals을(를) 배우세요 — 무료

브라우저에서 실제 코드를 작성하고 실행하며, 24/7 AI 튜터로부터 즉각적인 도움을 받고, 웹이나 앱에서 중단한 부분부터 계속 학습하세요.

코스
29
레슨
105

자주 묻는 질문

“머클 트리” 강의는 무료인가요?

네 — “머클 트리” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Web3 & DApp Development Fundamentals 강의 전체를 잠금 해제할 수 있습니다. Web3 & DApp Development Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.

“머클 트리”에서 뭘 배우나요?

효율적인 검증 브라우저에서 직접 실행하는 실습 코드로 Web3 & DApp Development Fundamentals을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Web3 & DApp Development Fundamentals을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Web3 & DApp Development Fundamentals은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.

“머클 트리” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Web3 & DApp Development Fundamentals 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Web3 & DApp Development Fundamentals 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 블록과 체인
  2. 머클 트리
  3. 블록체인의 해싱
  4. 분산 원장
← Web3 & DApp Development Fundamentals(으)로 돌아가기