Basics

Getting Started

TzGo is open-source software and available on Github at blockwatch-cc/tzgo. The complete GoDoc docu for TzGo is available at pkg.go.dev/blockwatch.cc/tzgo.

Download and install TzGo

go get -u blockwatch.cc/tzgo

Then import as

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

Connecting to Tezos RPC nodes

Most functions in TzGo can be used without the need to query an RPC node. In cases where you have to, e.g. to query on-chain state or send transactions, its important to understand the differences between Tezos node types and their configuration.

History modes

Tezos nodes can run in different history modes which keep different amounts of historic data around. All nodes, when fully synchronized, will always have state at the head and a few cycles in the past available. Only archive nodes will keep block metadata and historic account/contract states for all blocks in history, so if your application has the need to query old state it must run against an archive node. During the initial node synchronization, most RPC endpoints will return 404 or 5xx errors until the node has completed sync once.

ACL

Depending on where your TzGo application and Tezos nodes run you way want to enable localhost access --rpc-addr localhost:8732 or remote access --rpc-addr :8732. Since some RPCs may be resource intensive, the default policy in Tezos is to deny remote public access to all endpoints (only localhost access is permitted).

If you experience the following error

error: The server doesn't authorize this endpoint (ACL filtering). 

you may change the ACL policy in the node's configuration setting or by adding --allow-all-rpc 0.0.0.0 when starting your node. Only do this if your node is not reachable on a public IP address or if you have additional protection in place, e.g. in a reverse proxy that blocks critical endpoints.

When running the node inside a Docker container you must set an ACL policy (or disable it like above) since Docker uses an internal network interface and its own IP range that does not match the default localhost rules in Tezos.

Last updated