# 側鏈

### 側鏈（Sidechain）是一條與主網平行運作的獨立區塊鏈。它有自己的共識機制和規則，但可以透過「雙向橋接」與主網互通資產。

***

## 什麼是側鏈？

想像主網是一條繁忙的高速公路，車流量大到塞車。側鏈就像是旁邊新開的替代道路——它與高速公路平行，有自己的規則（也許速限不同），但透過交流道可以互相連通。

```
主網（高速公路）
    ↕ 雙向橋接（交流道）
側鏈（替代道路）
```

***

## 側鏈的運作原理

### 雙向錨定（Two-Way Peg）

這是側鏈最核心的技術。當你想把資產從主網移到側鏈：

1. **鎖定**：在主網上把代幣「鎖」起來
2. **鑄造**：在側鏈上「鑄造」等值的代幣
3. **使用**：在側鏈上自由使用
4. **銷毀**：想回主網時，銷毀側鏈代幣
5. **解鎖**：主網上的代幣解鎖

{% hint style="info" %}
**為什麼要這樣？**

因為同一筆資產不能同時存在於兩條鏈上。鎖定-鑄造的機制確保總量守恆。
{% endhint %}

***

## 為什麼需要側鏈？

### 1. 擴容

主網交易太慢、太貴？側鏈可以用不同的共識機制，實現更快、更便宜的交易。

### 2. 實驗新功能

想測試新技術但怕影響主網？在側鏈上實驗，安全又自由。

### 3. 特定應用

遊戲、社交等高頻低價值交易，放在側鏈上更合適。

***

## 側鏈 vs Layer 2

這兩個概念容易搞混：

| 特性     | 側鏈          | Layer 2           |
| ------ | ----------- | ----------------- |
| 安全性來源  | 自己的驗證者      | 依賴主網              |
| 共識機制   | 獨立的         | 使用主網的             |
| 去中心化程度 | 可能較低        | 繼承主網              |
| 代表項目   | Polygon PoS | Optimism、Arbitrum |

{% hint style="success" %}
**簡單記法**

側鏈是「獨立的朋友」，Layer 2 是「主網的延伸」。
{% endhint %}

***

## 著名的側鏈

| 側鏈          | 主網       | 特點        |
| ----------- | -------- | --------- |
| Polygon PoS | Ethereum | 低手續費、高速度  |
| Liquid      | Bitcoin  | 快速結算、隱私交易 |
| RSK         | Bitcoin  | 智能合約功能    |

***

## 側鏈的風險

### 1. 安全性較低

側鏈的安全性取決於自己的驗證者，不如主網那麼強。

### 2. 橋接風險

跨鏈橋是駭客最愛攻擊的目標。2022 年多起重大駭客事件都與跨鏈橋有關。

### 3. 中心化疑慮

部分側鏈的驗證者數量較少，可能存在中心化風險。

***

## 延伸閱讀

* [主網](/gei-kai-fa-zhe-de-zhi-nan/public-chain/mainnet.md) — 區塊鏈的正式網路
* [跨鏈](/gei-kai-fa-zhe-de-zhi-nan/public-chain/kua.md) — 不同區塊鏈之間的互通
* [Layer 2 總覽](/jie-jue-qu-kuai-lian-de-xiao-neng-ping-jing/layer2.md) — 另一種擴容方案

***

#### 參考資料

* [What is a Sidechain?](https://ethereum.org/en/developers/docs/scaling/sidechains/)
* [Polygon PoS](https://polygon.technology/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.0x1.academy/gei-kai-fa-zhe-de-zhi-nan/undefined-7.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
