---
title: "什麼是 testnet？"
description: "testnet 的用途是什麼？又該如何使用？"
---

# 什麼是 testnet？

隨著越來越多資金和使用者進入 Web3 及去中心化金融（DeFi）服務，安全性與可靠性對開發者而言變得愈發重要。開發者使用 testnet 來確保他們部署的[智能合約](https://www.alchemy.com/?a=62b31e85c0)與[應用程式](https://www.alchemy.com/dapps/top/defi-dapps)功能正常且安全。

開發者可以使用與 mainnet 相同的客戶端進行開發，但 testnet 運作在獨立的帳本上。這種分離創造了一個低風險的環境，讓開發者可以在不需承擔部署到 mainnet 成本的情況下進行測試與實驗。

讓我們更深入了解什麼是 testnet、使用 testnet 的優點，以及開發者如何存取它們。

## 什麼是 testnet？

Testnet 是測試用的區塊鏈網路，其運作方式與所對應的主網（mainnet）相似。由於它們運作在與 mainnet 分離的帳本上，testnet 上的代幣與 mainnet 上的交易和價值沒有任何關聯。這讓開發者可以在一個運作中的區塊鏈上自由地部署、測試及執行他們的專案。

在 mainnet 上失敗或犯錯的代價非常高，有時甚至無法挽回，因此開發者需要一個可以安心作業、不必承擔這些風險的環境。

安全性對於任何在去中心化平台上工作的開發者來說都是首要考量。在 testnet 上運作也有助於調查平台中的任何漏洞，同時教育開發者了解該平台的運作方式。對於為即將進行的網路升級而設立的 testnet 而言，在新開發的變更與 mainnet 合併之前，先調查這些變更的運作方式非常重要。

## Mainnet 與 testnet 的差異

大多數 testnet 都有獨立的錢包系統，以便在 mainnet 之外更容易管理代幣與交易。當使用像 [Alchemy](https://www.alchemy.com/blog/goerli-faucet-deprecation) 這樣的服務部署合約時，testnet 會有不同的 [Network ID](https://www.alchemy.com/chain-connect)。

舉例來說，在 Ethereum 網路上，mainnet 與各個 testnet 的 ID 如下：

[Ethereum mainnet](https://www.alchemy.com/rpc/ethereum) - 1

Sepolia testnet - 11155111

~~Ropsten testnet - 3~~（已棄用）

~~Rinkeby testnet - 4~~（已棄用）

~~Goerli testnet - 5~~（已棄用）

~~Kovan testnet - 42~~（已棄用）

這些 ID 用來確保合約被部署到正確的網路，並使用正確的錢包系統。相較於對應的 mainnet，testnet 的交易頻率並不高。由於 testnet 相較於 mainnet 具有多變的性質，其程式碼也不會公開發布。

## Ethereum testnet

Ethereum 有許多不同的 testnet，包括新推出的 Sepolia。

註：Ropsten、Kovan 與 Rinkeby testnet 已被 Ethereum 基金會棄用。此外，雖然你仍可以使用 Goerli testnet，但我們不建議這麼做，因為 Ethereum 基金會已宣布 [Goerli 即將被棄用](https://www.alchemy.com/overviews/sepolia-testnet)。因此，我們建議使用 [Sepolia testnet](https://www.alchemy.com/overviews/sepolia-testnet)，因為 Alchemy 完整支援 Sepolia，並提供免費的 [Sepolia faucet](https://sepoliafaucet.com/)。

### Sepolia

Sepolia 是一個由 Ethereum 核心開發者於 2021 年 10 月建立並持續維護的權威證明（proof-of-authority）testnet。

在 Ropsten testnet 達到 50000000000000000 的終端總難度（Terminal Total Difficulty，TTD）後，Sepolia 與 Goerli testnet 轉換為權益證明（proof-of-stake）共識機制，以模擬 Ethereum mainnet。

Sepolia 的設計目的是模擬嚴苛的網路條件，且區塊時間較短，這讓開發者能更快取得交易確認與反饋。

[**與 Goerli 等其他 testnet 相比**](https://www.alchemy.com/overviews/goerli-vs-sepolia)，Sepolia 的 testnet 代幣總量沒有上限，這代表使用 Sepolia 的開發者較不容易像使用 Goerli 一樣面臨 testnet 代幣稀缺的問題。

交易可以在 [Etherscan](https://sepolia.etherscan.io/) 上查看，Alchemy 也提供免費的 [Sepolia faucet](https://sepoliafaucet.com/)。由於 Goerli testnet 未來將被棄用，我們建議將 Sepolia 作為最佳的 testnet 選擇。

### Ropsten（已棄用）

[Ropsten testnet](https://www.alchemy.com/overviews/ropsten-testnet) 於 2016 年 11 月推出，同時支援 [Geth](https://www.alchemy.com/overviews/what-is-a-geth-node-and-how-to-run-one) 與 Parity Ethereum 節點軟體。

Ropsten testnet 讓開發者可以使用高度真實的 testnet 來進行開發，但這也讓網路暴露在若在 Ethereum mainnet 上執行會非常昂貴的攻擊風險之下。其中一次攻擊發生在 2017 年 2 月，攻擊者在網路上部署大量複雜交易，試圖使其癱瘓。網路後來恢復運作，並實施了防護措施以防止類似攻擊再次發生。

### Kovan（已棄用）

在 Ropsten 網路遭受攻擊之後，開發者需要替代的 testnet。Kovan 於 2017 年 3 月推出以滿足這項需求。Ropsten 與 Kovan 之間的主要差異在於它們的共識模型。

Kovan 使用權威證明（Proof-of-Authority，PoA）模型，只有特定節點被授權確認交易並新增區塊。由於這個 testnet 是由 [Parity](https://www.parity.io/technologies/ethereum/) 團隊建立的，開發者只能使用 Parity 節點軟體來存取它。

### Rinkeby（已棄用）

在 Kovan 推出之後，[Rinkeby testnet](https://www.alchemy.com/overviews/rinkeby-testnet) 於 2017 年由 Ethereum 團隊推出。與 Kovan 一樣，這個 testnet 使用改良版的 PoA 共識模型來確認交易。與 Kovan 不同的是，這個網路只支援 Geth 軟體，不支援 Parity。

### Goerli（已棄用）

Goerli 是一個結合 PoA 共識機制、並比 Rinkeby 與 Kovan 支援更廣泛節點軟體的 testnet。Goerli 同時支援 [Geth 與 Parity](https://www.alchemy.com//blog/secure-your-nodes-migrating-from-parity-to-geth)，以及 Nethermind 和 Hyperledger。

有了這樣更高程度的支援，Goerli 的使用率一直在上升。它也是第一個嘗試轉移到權益證明機制的 testnet，儘管在多次嘗試後遇到了問題。

交易可以[在 Etherscan 上查看](https://goerli.etherscan.io/)，Alchemy 也提供 [Goerli faucet](https://www.alchemy.com/overviews/kiln-testnet)。

<ImageBlock
  src="https://media.alchemy.com/1704206279-goerli-faucet.jpg"
  alt="Alchemy Goerli 水龍頭頁面，可用來領取免費的 testnet ETH"
  width={3340}
  height={1172}
  caption="Goerli 水龍頭"
/>

### Morden / kiln - 過去與未來

Morden 是第一個 Ethereum testnet。Ethereum 於 2016 年 11 月將其關閉，因為該網路遭遇多次攻擊，並被無用的資料塞滿，影響了效能。

[Kiln testnet](https://www.alchemy.com/overviews/kiln-testnet) 是在其他 Ethereum testnet 與 mainnet [轉移到權益證明共識機制](https://www.alchemy.com/overviews/ethereum-2-0-your-guide-for-2022)之前，最後一個計畫中的 testnet。

Ethereum 建立這個 testnet，是為了讓節點運營者與開發者能在該公司升級其他公開的 Ethereum testnet 之前先進行測試。

<EmbeddedTable
  table={{
    columns: [
      { key: "1", width: 200, title: "Proof of Work", dataType: "object" },
      { key: "2", width: 200, title: "Proof of Stake", dataType: "object" },
    ],
    data: [
      {
        "1": { title: "<p>Many miners compete to solve a puzzle the fastest</p>", tooltip: "", icon: "" },
        "2": { title: "<p>A single validator is selected to process the transaction</p>", tooltip: "", icon: "" },
        id: 0,
      },
    ],
  }}
/>

## 結論

使用 testnet 是在任何區塊鏈網路上開發應用程式的關鍵步驟，為了確保 Web3 的成長，開發者與使用者都需要對他們所使用的智能合約與應用程式抱有信心。

Testnet 是關鍵的[區塊鏈開發者工具](https://www.alchemy.com/overviews/20-blockchain-development-tools)，能夠建立起隨著 Web3 應用程式持續成長，使用者將愈發要求的安全性與穩定性。

想開始在 Ethereum testnet 上建構去中心化應用程式嗎？[建立免費的 Alchemy 開發者帳號](https://www.alchemy.com/?a=62b31e85c0)，開始建構！

## 常見問題

### 什麼是 testnet？

Testnet 是測試用的區塊鏈網路，其運作方式與 mainnet 相似，但運作在獨立的帳本上，讓開發者可以在不必承擔使用 mainnet 的風險與成本的情況下，部署、測試及執行專案。

### Testnet 與 Mainnet 有什麼差異？

Testnet 運作在與 mainnet 分離的帳本上，使用沒有實際價值的模擬代幣，讓開發者可以安全地進行測試；而 mainnet 則處理帶有實際加密貨幣資產的即時交易。

### Testnet 代幣有價值嗎？

沒有，testnet 代幣與 mainnet 上的交易和價值沒有任何關聯，也不具有任何實際的金錢價值。

### 為什麼開發者要使用 testnet？

開發者使用 testnet 來確保他們的智能合約與應用程式在部署到 mainnet 之前功能正常且安全，藉此創造一個低風險的測試與實驗環境。

### 我應該使用哪一個 Ethereum testnet？

Alchemy 建議使用 Sepolia testnet，因為許多其他 Ethereum testnet，如 Ropsten、Kovan、Rinkeby 都已被棄用，而 Goerli 也將很快被 Ethereum 基金會棄用。

### Sepolia 與其他 testnet 有何不同？

Sepolia 擁有較短的區塊時間，能讓交易確認更快，並模擬嚴苛的網路條件，同時 testnet 代幣數量沒有上限，讓開發者較不容易面臨代幣稀缺的問題。

### Testnet 如何提升區塊鏈安全性？

Testnet 讓開發者能在部署到 mainnet 之前，先調查漏洞、測試網路升級並找出問題，而在 mainnet 上失敗的代價會非常高，甚至可能無法挽回。

### 任何人都可以存取 testnet 嗎？

可以，需要測試應用程式的開發者都能存取 testnet，且像 Alchemy 這樣的服務會提供免費的 faucet，讓開發者取得 testnet 代幣進行實驗。
