Talk to your dragonchain.
These docs are auto-generated.
go get https://github.com/dragonchain/dragonchain-sdk-go
import (
"fmt"
"net/http"
"github.com/dragonchain/dragonchain-sdk-go"
)
httpClient := &http.Client{}
myDcID := "3f2fef78-0000-0000-0000-9f2971607130";
myCreds := dragonchain.NewCredentials(mydcID, apiKey, apiKeyID, dragonchain.HashSHA256)
client := dragonchain.NewClient(myCreds, baseURL, httpClient)
call, err := await client.GetBlock("block-id-here");
if err != nil {
fmt.Println("Something went wrong!");
fmt.Printf("HTTP status code from chain: %s", call.status);
fmt.Printf("Error response from chain: %s", call.response);
}
fmt.Println("Successful call!");
fmt.Printf("Block: %s", call.response);
searchResult := client.QueryTransactions(Query.NewQuery("tag=MyAwesomeTransactionTag"))
This is fine for quick tests. For actual production use, you should use the credential ini file or environment variables
newHttpClient := &http.Client{}
client.overrideCredentials("AUTH_KEY_ID","AUTH_KEY", newHttpClient)
In order to use this SDK, you need to have an Auth Key as well as an Auth Key ID for a given dragonchain. This can be loaded into the sdk in various ways, and are checked in the following order of precedence:
- The environment variables
AUTH_KEY
andAUTH_KEY_ID
can be set with the appropriate values - Write an ini-style credentials file at
~/.dragonchain/credentials
(or on Windows:%LOCALAPPDATA%\dragonchain\credentials
) where the section name is the dragonchain id, with values forauth_key
andauth_key_id
like so:
[35a7371c-a20a-4830-9a59-5d654fcd0a4a]
auth_key_id = JSDMWFUJDVTC
auth_key = n3hlldsFxFdP2De0yMu6A4MFRh1HGzFvn6rJ0ICZzkE
Dragonchain is happy to welcome contributions from the community. You can get started here.