新增 Fabric Organizations 至網路

本主題包含將 Hyperledger Fabric 組織加入至 Oracle Blockchain Platform 網路的相關資訊。

將 Fabric 組織加入 Oracle Blockchain Platform 網路的一般工作流程

以下是 Fabric 組織和 Oracle Blockchain Platform 創辦人組織將 Fabric 組織加入 Oracle Blockchain Platform 網路所需的任務。

作業 這是誰? 描述 其他資訊
建立 Fabric 組織的憑證檔案 Fabric 組織 尋找 Fabric 組織的 Admin、CA 和 TLS 憑證資訊,並用來撰寫 JSON 憑證檔案。 建立 Fabric Organization 的憑證檔案
將 Fabric 組織的憑證檔案上傳至 Oracle Blockchain Platform 網路 創始人組織 使用主控台來上傳和匯入 Fabric 組織的憑證檔案,以將 Fabric 組織新增至網路。 匯入憑證以新增組織至網路
建立管道 創始人組織 建立新通道,並在其中新增 Fabric 組織。 建立管道
從發起者匯出訂購服務設定 創始人組織 將創始人的訂購服務設定輸出到 JSON 檔案,並將檔案發送到 Fabric 組織。 將參與者或橫向擴展 OSN 加入創辦人的訂購服務
編寫排序器憑證檔案 Fabric 組織 建立一個名為 orderer.pem 的檔案,其中包含 tlscacert 資訊。

移至匯出的訂購服務設定檔案,並複製 tlscacert 資訊。將 tlscacert 資訊貼到 orderer.pem 檔案後,您必須以換行字元取代 \n 的所有實例。

orderer.pem 檔案必須具有下列格式:

-----BEGIN CERTIFICATE-----
... 
...
... 
-----END CERTIFICATE-----
建立 Fabric Organization 的憑證檔案
提供訂購服務設定值 創始人組織 開啟訂購服務設定值檔案,並尋找訂購服務的地址和連接埠,然後將它們提供給 Fabric 組織。舉例而言:
"orderingServiceNodes": [
{
"address": "grpcs://example_address:7777",
...
}]
新增 Fabric 組織至網路 Fabric 組織 Fabric 組織會將憑證複製到其環境中、設定環境變數、擷取基因組區塊、加入通道,以及安裝鏈碼。 準備使用 Oracle Blockchain Platform Network 的 Fabric 環境

建立 Fabric Organization 的憑證檔案

如果要讓 Fabric 組織能夠加入 Oracle Blockchain Platform 網路,則必須撰寫包含其 admincerts、cacerts 和 tlscacerts 資訊的憑證檔案。Oracle Blockchain Platform 創辦人組織會匯入此檔案,以將 Fabric 組織新增至網路。

Fabric 憑證資訊會儲存在 Fabric 組織之 MSP 資料夾中的 PEM 檔案中。例如,network_name_example/crypto-config/peerOrganizations/example_org.com/msp/

憑證檔案必須以 JSON 撰寫,且必須包含下列欄位。對於所有憑證,當您將憑證資訊複製到 JSON 檔案中時,必須以 \n 取代每一行,如此一來,該資訊就會全部位於一行且不包含空格,如下列範例所示。

  • mspid — 指定 Fabric 組織的名稱。

  • type — 指示組織為網路參與者。此值必須是參與者
  • admincert — 包含組織之「管理」憑證檔案的內容:Admin@example_org.com-cert.pem

  • cacert — 包含組織 CA 憑證檔案的內容:ca.example_org-cert.pem

  • tlscacert — 包含組織之 TLS 憑證檔案的內容:tlsca.example_org-cert.pem

  • intermediatecerts — 此選擇性元素包含中繼 CA 憑證檔案的內容。除非有中介 CA 憑證檔案,否則請勿指定此元素。
  • nodeouidentifiercert — 此段落包含識別節點 OU 角色的憑證。
  • adminouidentifiercert — 包含組織用於識別節點 OU 管理角色的憑證檔案內容。如果您不需要管理員角色,可以使用 cacert 檔案內容或中間憑證檔案內容作為管理 ID 內容。

  • clientouidentifiercert — 包含組織用於識別節點 OU 從屬端角色的憑證檔案內容。

  • ordererouidentifiercert — 包含組織用於識別節點 OU 排序器角色的憑證檔案內容。如果您不需要排序器角色,可以使用 cacert 檔案內容或中間憑證檔案內容作為 ordererouidentifier 內容。

  • peerouidentifiercert — 包含組織用於識別節點 OU 對等角色的憑證檔案內容。

建立與下列範例類似的檔案:
{
  "mspID": "examplemspID",
  "type":  "Participant",
  "certs": { 
   "admincert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n",
   "cacert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n",
   "tlscacert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n"
   "nodeouidentifiercert": {
      "adminouidentifiercert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n",
      "clientouidentifiercert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n",
      "ordererouidentifiercert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n",
      "peerouidentifiercert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n"
    }
  }
} 
    

準備使用 Oracle Blockchain Platform 網路的 Fabric 環境

您必須先修改 Fabric 組織的環境,才能使用 Oracle Blockchain Platform 網路。

確認下列先決條件作業已完成。如需詳細資訊,請參閱將 Fabric 組織加入 Oracle Blockchain Platform Network 的典型工作流程

  • Fabric 組織的憑證檔案已建立並傳送給 Oracle Blockchain Platform 網路創始人。

  • 網路創始人上傳了憑證檔案,將 Fabric 組織新增至網路。

  • 網路創辦人會建立新的通道,並在其中新增 Fabric 組織。

  • 網路創始人下載了它的訂購服務設定值,並傳送到 Fabric 組織。

  • Fabric 組織會建立訂購者憑證檔案。

  • 網路創始人將訂購服務位址和連接埠提供給 Fabric 組織。

您必須新增 Fabric 組織,並安裝並測試鏈碼。

  1. 瀏覽至 Fabric Network 目錄,並啟動對等容器。

  2. 使用此指令抓取頻道的 genesis 區塊 :

    peer channel fetch 0 mychannel.block -o ${orderer_addr}:${orderer_port} -c mychannel --tls --cafile orderer.pem --logging-level debug  

    其中:

    • {orderer_addr} 是 Founder 的排序器地址。

    • {orderer_port} 是 Founder 的連接埠號碼。

    • -c mychannel 是 Founder 建立的通路名稱。這是 Fabric 組織在 Oracle Blockchain Platform 網路上傳送和接收交易的管道。

    • orderer.pem 是 Founder 的排序器憑證檔案。

  3. 使用此命令加入通道:

    peer channel join -b mychannel.block -o ${orderer_addr}:${orderer_port} --tls --cafile orderer.pem --logging-level debug
  4. 使用此命令安裝鏈碼:

    peer chaincode install -n mycc -v 1.0 -l "golang" -p ${CC_SRC_PATH}

    其中 CC_SRC_PATH 是包含鏈碼的資料夾。

  5. 使用此命令建立鏈碼:

    peer chaincode instantiate -o  ${orderer_addr}:${orderer_port} --tls --cafile orderer.pem -C mychannel -n mycc -l golang -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P <policy_string> --logging-level debug
  6. 使用此命令呼叫鏈碼:

    peer chaincode invoke -o ${orderer_addr}:${orderer_port}  --tls true --cafile orderer.pem -C mychannel -n mycc -c '{"Args":["invoke","a","b","10"]}' --logging-level debug
  7. 使用此命令查詢鏈碼:

    peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'  --logging-level debug