# README
Dragonchain Golang SDK
Talk to your dragonchain.
⚠️Warning!⚠️ This repository is not currently actively maintained. We will still welcome PRs for updates, but note that parts of this SDK may not be fully working.
Method Quicklinks
These docs are auto-generated.
Installation
go get https://github.com/dragonchain/dragonchain-sdk-go
Examples
GetBlock
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);
QueryTransactions
searchResult := client.QueryTransactions(Query.NewQuery("tag=MyAwesomeTransactionTag"))
OverrideCredentials
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)
Configuration
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
Contributing
Dragonchain is happy to welcome contributions from the community. You can get started here.
# Functions
GetCredentialConfigs returns.
NewClient creates a new instance of client.
NewCredentials uses the provided values to create a new Credentials instance for the given chain.
NewQuery constructs a Query based on provided parameters.
NewRequestError returns a formatted ErrFailedRequest object from the chain's http response.
# Constants
Supported hash functions.
Supported hash functions.
Supported hash functions.
MaxBulkPutSize is the configurable limit of how many txn can be included in a bulk operation.
# Variables
BitcoinNetworks supported for interchain capabilities.
ConfigFilePath points to the location of the Configuration file Default on windows '%LOCALAPPDATA%\dragonchain\credentials' Default on linux '$HOME/.dragonchain/credentials' This may be overridden before creating Credentials.
Environment variables used to get chainID and Keys.
Environment variables used to get chainID and Keys.
Environment variables used to get chainID and Keys.
ErrDCTimeout is thrown when the chain API returns a timeout.
ErrInvalidLimit is thrown when a negative limit is provided.
ErrInvalidOffset is thrown when a negative offset is provided.
ErrMaxBulkSizeExceeded is thrown when bulk requests exceed MaxBulkPutSize.
ErrNoConfigurationFileFound is returned if no config was found in ConfigFilePath.
ErrNoCredentials is thrown if no credentials file can be found.
ErrUnsupportedHashAlgo is thrown when an unsupported hash method is provided.
EthereumNetworks supported for interchain capabilities.
# Structs
AuthKey defines the structure of the chain's HMAC authorization keys.
BitcoinOutputs are optional outputs for a bitcoin transaction.
BitcoinTransaction represents a transaction on a bitcoin chain.
Block defines the structure of a finalized block.
BlockHeader defines the structure of a block's header.
BlockProof defines the structure of a signature proof.
Client defines the structure of the DragonchainSDK client.
Configuration defines the SDK configuration of chainID and AuthKeys.
Contract defines the structure of a deployed smart contract.
ContractConfiguration defines the structure of a request to create a new smart contract.
ContractStatus defines the status object for contracts.
CreateTransaction defines the transaction schema for dragonchain.
Credentials implements the Authenticator interface to generate authentication headers.
CustomIndexStructure defines the valid format of custom indexes on a transaction type.
ErrFailedRequest defines the structure of an error returned by the chain.
EthereumTransaction represents a transaction on an ethereum chain.
Factor defines the complete factor on a dragonchain.
GetSmartContractHeap defines the request format for getting a key from a Smart Contract's heap.
Header defines the HTTP headers required for dragonchain authentication.
L1Verification is a representation of an L1 block verified by an L2 chain.
L2Verification is a representation of an L2 block verified by an L3 chain.
L3Verification is a representation of an L3 block verified by an L4 chain.
L4Verification is a representation of an L4 block verified by an L4 chain.
Proof defines the proof object returned by L1 dragonchains.
Query defines the structure of a lucene query on the Dragonchain.
Response defines the standard response all chains will use.
Transaction defines the complete transaction on a dragonchain.
TransactionType defines the properties of a valid Dragonchain transaction type.
Verification is a representation of the verification object for a block.
# Interfaces
Authenticator generates the authentication header for requests to chain.