Code Monkey home page Code Monkey logo

dragonchain-sdk-go's Introduction

Dragonchain Golang SDK

Build Status Test Coverage License

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:

  1. The environment variables AUTH_KEY and AUTH_KEY_ID can be set with the appropriate values
  2. 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 for auth_key and auth_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.

dragonchain-sdk-go's People

Contributors

anmil avatar cheeseandcereal avatar deanshelton913 avatar rdaquilante avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

appbootup

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.