2025-11-10 16:44:59 -05:00
2025-11-10 16:44:59 -05:00
2025-11-10 16:44:59 -05:00
2025-11-10 16:44:59 -05:00
2025-11-10 16:44:59 -05:00
2025-11-10 16:44:59 -05:00
2025-11-10 16:44:59 -05:00
2025-11-10 16:44:59 -05:00
2025-11-10 16:44:59 -05:00
2025-11-10 16:44:59 -05:00
2025-11-10 16:44:59 -05:00
2025-11-10 16:44:59 -05:00
2025-11-10 16:44:59 -05:00
2025-11-10 16:44:59 -05:00

Dragonchain Go SDK

A self-contained Go SDK for interacting with Dragonchain nodes.

Installation

go get git.dragonchain.com/dragonchain/dragonchain-prime-sdk-go

Usage

package main

import (
    "fmt"
    "log"

    "git.dragonchain.com/dragonchain/dragonchain-prime-sdk-go"
    "git.dragonchain.com/dragonchain/dragonchain-prime-sdk-go/models"
)

func main() {
    // Initialize the SDK
    client := sdk.NewDragonchainSDK(
        "your-public-id",
        "your-auth-key-id",
        "your-auth-key",
        "https://your-dragonchain-endpoint.com",
    )

    // Check system health
    if err := client.System.Health(); err != nil {
        log.Fatal("Health check failed:", err)
    }

    // Get system status
    status, err := client.System.Status()
    if err != nil {
        log.Fatal("Failed to get status:", err)
    }
    fmt.Printf("Chain ID: %s, Level: %d\n", status.ID, status.Level)

    // Create a transaction
    txn := &models.TransactionCreateRequest{
        TxnType: "my-transaction-type",
        Payload: map[string]interface{}{
            "message": "Hello Dragonchain",
        },
        Tag: "example-tag",
    }

    resp, err := client.Transaction.Create(txn)
    if err != nil {
        log.Fatal("Failed to create transaction:", err)
    }
    fmt.Printf("Created transaction: %s\n", resp.TransactionID)
}

Available Endpoints

System

  • Health() - Check system health
  • Status() - Get system status

Transaction

  • Create(req) - Create a new transaction
  • CreateBulk(req) - Create multiple transactions
  • Get(transactionID) - Get transaction by ID

Transaction Type

  • Create(req) - Create a new transaction type
  • Get(txnType) - Get transaction type by name
  • List() - List all transaction types
  • Delete(txnType) - Delete a transaction type

Smart Contract

  • Create(req) - Create a new smart contract
  • Get(contractID) - Get smart contract by ID
  • List() - List all smart contracts
  • Update(contractID, req) - Update a smart contract
  • Upload(contractID, req) - Upload smart contract code
  • Delete(contractID) - Delete a smart contract

Block

  • Get(blockID) - Get block by ID

Authentication

The SDK uses HMAC-SHA256 authentication. You need to provide:

  • publicID - Your Dragonchain public ID
  • authKeyID - Your authentication key ID
  • authKey - Your authentication key
  • baseURL - The base URL of your Dragonchain node (e.g., "https://mychain.dragonchain.com")
Description
No description provided
Readme Apache-2.0 42 KiB
Languages
Go 100%