go-stacks
Introduction
go-stacks
is a golang sdk for interacting with the stacks blockchain.
This SDK was generated using the Hiro's OpenAPI specification & API Matic with some modifications. It only has one dependancy, and that dependancy has none.
Requirements
The SDK requires Go version 1.22 or above.
Building
Install Dependencies
Resolve all the SDK dependencies, using the go get
command.
TODOs
- fix and improve testing
- implement (de)serializing transactions
Quick Start
Note: Documentation for the client can be found here.
package main
import (
"context"
"fmt"
"github.com/cbadawi/go-stacks/stacks"
)
func main() {
config := stacks.CreateConfiguration(
stacks.WithBaseUri(stacks.MAINNET_URI),
stacks.WithVerbose(true),
)
principal := "SP3KANBW2C4E5BRPWNTWZCCDGF2F87CW9D9KV0FFK"
unanchored := false
untilBlock := "600000"
client := stacks.NewClient(config)
accountsController := client.AccountsController()
ctx := context.Background()
apiResponse, err := accountsController.GetAccountBalance(ctx, principal, &unanchored, &untilBlock)
if err != nil {
fmt.Println(err)
}
fmt.Println(apiResponse.Data.Stx.Balance)
}
List of APIs
Classes Documentation