Algorand 開發者SDK釋出-附簡單除錯程式碼

買賣虛擬貨幣


隨著Algorand接近主網的推出,團隊推出Go SDK提供給開發者使用,這標誌著另一個里程碑,它使開發人員能更加夠輕鬆地在Algorand之上構建應用程式。 Algorand一直致力於設計和實施介面,透過繼續提供給開發人員更好的資源,使使用者能夠參與到無邊界經濟Borderless economy。

除了godoc.com上的文件之外,該專案的自述檔案還提供瞭如何使用SDK執行常見任務的例子。 Go SDK目前可用於Algorand的TestNet,目前可透過此應用程式訪問。 TestNet將很快開放。建議使用者檢視github儲存庫並分享反饋。

Go SDK的推出是在本月早些時候Algorand開發者網站釋出之後釋出的。 Algorand目前還提供REST API,支援與Algorand節點的核心服務直接互動:協議和金鑰管理。為這些API提供了開放API文件,使其可以直接使用它們。

在許多客戶端庫上還有進一步的工作,它們還提供了一組廣泛的面向任務的功能(轉賬簽名,地址生成等),以支援其他常見用例。

如需瞭解即將推出的其他語言的使用者,TestNet和MainNet新聞,可檢視https://www.algorand.com/contact   SDK快速入門要下載SDK,請開啟終端並使用`go get`命令。

go get -u github.com/algorand/go-algorand-sdk/...

API客戶端旨在用於執行algod和kmd的例項。 這些過程在developer.algorand.org上描述。 要連線到其中一個程序,您必須首先知道其API通證及其執行的埠。 這兩個程序中的每一個都有一個.token和.net檔案,它位於各自的資料目錄中,並帶有此資訊。

要使用algod檢查節點的狀態,請檢視以下示例:

import ("encoding/json""fmt"

"github.com/algorand/go-algorand/sdk/client/algod"

)

// These constants represent the algod

// REST endpoint and the corresponding

// API token. You can retrieve these from the

// `algod.net` and `algod.token` files in the algod data directory.

const algodAddress = "http://localhost:8080"

const algodToken = "e48a9bbe064a08f19cde9f0f1b589c1188b24e5059bc661b31bd20b4c8fa4ce7"

func main() {

// Create an algod client

algodClient, err := algod.MakeClient(algodAddress, algodToken)

if err != nil {

fmt.Printf("failed to make algod client: %s\n", err)

return

}

// Get algod status

nodeStatus, err := algodClient.Status()

if err != nil {

fmt.Printf("error getting algod status: %s\n", err)

return

}

fmt.Printf("algod last round: %d\n", nodeStatus.LastRound)

fmt.Printf("algod time since last round: %d\n", nodeStatus.TimeSinceLastRound)

fmt.Printf("algod catchup: %d\n", nodeStatus.CatchupTime)

fmt.Printf("algod latest version: %s\n", nodeStatus.LastVersion)import (

"encoding/json"

"fmt"

"github.com/algorand/go-algorand/sdk/client/algod"

)

// These constants represent the algod

// REST endpoint and the corresponding

// API token. You can retrieve these from the

// `algod.net` and `algod.token` files in the algod data directory.

const algodAddress = "http://localhost:8080"

const algodToken = "e48a9bbe064a08f19cde9f0f1b589c1188b24e5059bc661b31bd20b4c8fa4ce7"

func main() {

// Create an algod client

algodClient, err := algod.MakeClient(algodAddress, algodToken)

if err != nil {

fmt.Printf("failed to make algod client: %s\n", err)

return

}

// Get algod status

nodeStatus, err := algodClient.Status()

if err != nil {

fmt.Printf("error getting algod status: %s\n", err)

return

}

fmt.Printf("algod last round: %d\n", nodeStatus.LastRound)

fmt.Printf("algod time since last round: %d\n", nodeStatus.TimeSinceLastRound)

fmt.Printf("algod catchup: %d\n", nodeStatus.CatchupTime)

fmt.Printf("algod latest version: %s\n", nodeStatus.LastVersion)

}

免責聲明:

  1. 本文版權歸原作者所有,僅代表作者本人觀點,不代表鏈報觀點或立場。
  2. 如發現文章、圖片等侵權行爲,侵權責任將由作者本人承擔。
  3. 鏈報僅提供相關項目信息,不構成任何投資建議

推荐阅读

;