Socket
Book a DemoInstallSign in
Socket

github.com/Dan6erbond/algogovernance

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/Dan6erbond/algogovernance

Source
Go
Version
v1.0.7
Version published
Created
Source

algogovernance

Go Reference

A Golang API wrapper for Algorand's Governance API and CLI tool.

Installation

Add the Go package:

$ go get github.com/Dan6erbond/algogovernance

Install the CLI tool:

$ go install github.com/Dan6erbond/algogovernance

Quick Start

Algorand's Governance API is a RESTful API that doesn't require keys or tokens to access, which is why all its methods are available under the pkg/client module.

Fetching the current period and its governors:

package main

import (
	"github.com/Dan6erbond/algogovernance/pkg/client"
)

func main() {
	activePeriod, _ := client.GetActivePeriod()
  governors, _ := client.GetPeriodGovernors(activePeriod.Slug, "", "", "", "cursor", "", "", "")
  for governors.HasNext() {
    governors, _ = governors.GetNext()
  }
}

algogovernance also comes with helpers to estimate rewards for a given governor and governance period. Those are found in the pkg/rewards module.

Getting the estimated rewards for the current period:

package main

import (
	algoRewards "github.com/Dan6erbond/algogovernance/pkg/rewards"
)

func main() {
  address := "3RYOY2LTPC6GLT3ZYE4LUFGGAEMY7GRENZQO7RFNGK2LGCV77QNASK6C6Y"
  rewards, _ := algoRewards.GetRewardsForCurrentPeriod(address)
}

CLI Tool

The CLI tool is built with Cobra and uses Viper configuration for governor wallet addresses. It supports the following commands:

  • cfg: View the current configuration.
  • currentPeriod: Get an overview of the current period and expected governance rewards.
  • rewards: Get the expected rewards for a given period, defaults to the current active period.

Documentation

The documentation is available at pkg.go.dev: algogovernance command - github.com/Dan6erbond/algogovernance - pkg.go.dev

License

This package is licensed under the MIT license.

FAQs

Package last updated on 04 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts