We're thrilled to share the first public release of TzGo, our Golang SDK for the Tezos blockchain. We've been using different parts of TzGo in the backend of our public block explorer TzStats for years. Now that demand for reliable and fast access to Tezos on-chain data is growing fast, it is important to us that we make this powerful and easy-to-use middleware available as open-source to the wider community to prevent lock-in to centralized data APIs as we see happening with other blockchains.

TzGo is fully compatible with the Tezos Node RPC, supports binary and JSON encoded Micheline, and works with all currently deployed protocols. It is perfectly suited for building reliable high-performance backend applications from small-scale all the way to enterprise level.

The SDK comes with a permissive license and is free to use in commercial and non-commercial projects. At Blockwatch we are committed to keeping interfaces stable, provide long-term support, and update TzGo on a regular basis to stay compliant with the most recent Tezos protocol.

TzGo features

Developers can use TzGo to read, monitor, decode, translate, analyze and debug data from the Tezos blockchain, and in particular from Tezos smart contracts. TzGo works in a fully decentralized way without the need for 3rd party APIs. TzGo currently contains

  • a low-level Tezos types library tzgo/tezos to handle all sorts of hashes, addresses and other types found on-chain
  • a powerful Micheline library tzgo/micheline to decode and translate data found in smart contract calls, storage, and bigmaps
  • a RPC library tzgo/rpc for accessing the Tezos Node RPC

Tezos protocol support for

  • Florence v009
  • Edo v008
  • Delphi v007
  • Carthage v006
  • Babylon v005
  • Athens v004
  • Alpha v001-v003

TzGo Roadmap

Right now, our main focus is on correctness, stability, and compliance with the Tezos protocol. For the time being, we consider TzGo in beta status until we have integrated a sufficient amount of feedback from both our enterprise customers and community users. Two big milestones are on our roadmap:

  • v1: read-only access to all Tezos on-chain and node-level data
  • v2: transaction creation, signing, simulation and injection

As new protocols are proposed and later deployed, we will upgrade TzGo to support new features as soon as practically feasible and as demand for such features exists. For example, we don't fully support Sapling and Lazy Storage updates yet but will add support in the future as usage of these features becomes more widespread.

Micheline Support

Tezos uses Micheline for encoding smart contract data and code. Micheline is strongly typed, but its JSON format is verbose and the encoding can be ambiguous which makes it often hard to use. Therefore, we built a new Micheline library that can decode and re-encode binary and JSON formats and unfold values based on annotated types, so that it's easy to convert from Micheline to native Go types.

import (
	"blockwatch.cc/tzgo/micheline"
	"blockwatch.cc/tzgo/rpc"
	"blockwatch.cc/tzgo/tezos"
)

// we use the Baker Registry on mainnet as example
addr := tezos.MustParseAddress("KT1ChNsEFxwyCbJyWGSL3KdjeXE28AY1Kaog")

// init RPC client
c, _ := rpc.NewClient("https://rpc.tzstats.com", nil)

// fetch the contract's script and most recent storage
script, _ := c.GetContractScript(ctx, addr)

// declare Go type
type BakerRegistryStorage struct {
	// ommitted for brevity
}

// map Micheline primitives into Go type
val := micheline.NewValue(script.StorageType(), script.Storage)

reg := &BakerRegistryStorage{}
_ = val.Unmarshal(reg)

When Micheline values are packed into byte sequences by the PACK instruction, TzGo can unpack and guess the embedded type info which makes it easy to retrieve UFT8-encoded strings and nested records.

Getting Help and Further Reading

Visit and fork our public Github repositories linked below. For questions and support join our Discord or open an issue.