<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                --- 概述: 用Go初始化客戶端以連接以太坊的教程 --- # 初始化客戶端 用Go初始化以太坊客戶端是和區塊鏈交互所需的基本步驟。首先,導入go-etherem的`ethclient`包并通過調用接收區塊鏈服務提供者URL的`Dial`來初始化它。 若您沒有現有以太坊客戶端,您可以連接到infura網關。Infura管理著一批安全,可靠,可擴展的以太坊[geth和parity]節點,并且在接入以太坊網絡時降低了新人的入門門檻。 ```go client, err := ethclient.Dial("https://mainnet.infura.io") ``` 若您運行了本地geth實例,您還可以將路徑傳遞給IPC端點文件。 ```go client, err := ethclient.Dial("/home/user/.ethereum/geth.ipc") ``` 對每個Go以太坊項目,使用ethclient是您開始的必要事項,您將在本書中非常多的看到這一步驟。 ## 使用Ganache [Ganache](https://github.com/trufflesuite/ganache-cli)(正式名稱為testrpc)是一個用Node.js編寫的以太坊實現,用于在本地開發去中心化應用程序時進行測試。現在我們將帶著您完成安裝并連接到它。 首先通過[NPM](https://www.npmjs.com/package/ganache-cli)安裝ganache。 ```bash npm install -g ganache-cli ``` 然后運行ganache cli客戶端。 ```bash ganache-cli ``` 現在連到`http://localhost:8584`上的ganache RPC主機。 ```go client, err := ethclient.Dial("http://localhost:8545") if err != nil { log.Fatal(err) } ``` 在啟動ganache時,您還可以使用相同的助記詞來生成相同序列的公開地址。 ```bash ganache-cli -m "much repair shock carbon improve miss forget sock include bullet interest solution" ``` 我強烈推薦您通過閱讀其[文檔](http://truffleframework.com/ganache/)熟悉ganache。 --- ### 完整代碼 ```go package main import ( "fmt" "log" "github.com/ethereum/go-ethereum/ethclient" ) func main() { client, err := ethclient.Dial("https://mainnet.infura.io") if err != nil { log.Fatal(err) } fmt.Println("we have a connection") _ = client // we'll use this in the upcoming sections } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看