0Pricing
Web3 & DApp Development Fundamentals · บทเรียน

เหตุใดจึงต้องใช้เลเยอร์ 2

การขยาย Ethereum

เหตุใดจึงต้องใช้เลเยอร์ 2 เป็นบทเรียน Web3 & DApp Development Fundamentals ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Web3 & DApp Development Fundamentals และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Web3 & DApp Development Fundamentals มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

The Scaling Problem

Ethereum can only process a limited number of transactions per second. When demand surges, blocks fill up and gas fees spike.

Layer 2 (L2) solutions exist to scale throughput without sacrificing the security of the base chain.

Layer 1 vs Layer 2

Layer 1 (L1) is the base blockchain like Ethereum. Layer 2 is a separate system that processes transactions off the main chain but settles back to it.

  • L1: maximum security, limited throughput
  • L2: high throughput, inherits L1 security

The Blockchain Trilemma

The trilemma says a chain struggles to be simultaneously scalable, secure, and decentralized at L1.

L2s sidestep this by handling scale off-chain while leaning on L1 for security and decentralization.

How Gas Fees Arise

Every operation costs gas, paid in ETH. Limited block space means users bid against each other, pushing fees up during congestion.

By moving execution off L1, L2s drastically cut the cost per transaction.

L1 swap fee:  ~$15 during congestion
L2 swap fee:  ~$0.05
// same action, far cheaper

Inheriting Security

The key insight of L2s: they do the heavy computation off-chain but post data or proofs to L1.

This lets them inherit Ethereum's security rather than bootstrapping a brand-new validator set.

Batching Transactions

L2s batch many transactions together and submit a single compressed summary to L1.

Hundreds of L2 transactions share the cost of one L1 submission, slashing per-user fees.

L2 collects 500 transactions
-> compress into 1 batch
-> post batch to L1
// cost split across all 500

Rollups: The Dominant Approach

The leading L2 design is the rollup. Rollups execute transactions off-chain and post the resulting data to L1, where it can be verified.

We will explore Optimistic and ZK rollups in detail next lesson.

Other Scaling Approaches

Besides rollups, there are:

  • State channels — off-chain payment channels
  • Sidechains — independent chains with their own security
  • Validiums — ZK proofs with off-chain data

Each trades off security, cost, and complexity differently.

Sidechains Are Not True L2

A sidechain runs in parallel with its own consensus and validators. It does not inherit L1 security.

If a sidechain's validators are compromised, funds can be lost — a key difference from rollups.

User Experience Improvements

For users, L2s mean near-instant confirmations and cheap fees, while still being able to bridge back to Ethereum.

This makes everyday actions like swaps, mints, and games economically viable on-chain.

Putting It Together

Layer 2s scale Ethereum by executing transactions off-chain and batching results to L1, inheriting its security while cutting fees dramatically.

Rollups lead the way, with sidechains and channels as alternatives. Next: how rollups actually work.

Quick Check

Test your Layer 2 fundamentals.

Recap: Why Layer 2

You learned that:

  • L2s scale L1 by executing off-chain and settling on-chain
  • They sidestep the trilemma and cut gas fees
  • Batching shares L1 costs across many transactions
  • Rollups inherit L1 security; sidechains do not

Next: rollups in depth.

คำถามที่พบบ่อย

บทเรียน “เหตุใดจึงต้องใช้เลเยอร์ 2” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “เหตุใดจึงต้องใช้เลเยอร์ 2” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Web3 & DApp Development Fundamentals ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Web3 & DApp Development Fundamentals มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “เหตุใดจึงต้องใช้เลเยอร์ 2”

การขยาย Ethereum คุณปฏิบัติ Web3 & DApp Development Fundamentals ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Web3 & DApp Development Fundamentals หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Web3 & DApp Development Fundamentals บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน

บทเรียน “เหตุใดจึงต้องใช้เลเยอร์ 2” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Web3 & DApp Development Fundamentals นี้ได้ไหม

ได้ บทเรียน Web3 & DApp Development Fundamentals ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. เหตุใดจึงต้องใช้เลเยอร์ 2
  2. โรลอัป
  3. การเชื่อมสินทรัพย์
  4. การเลือกเลเยอร์ 2
← กลับไปที่ Web3 & DApp Development Fundamentals