GoTezos Q4 Update

Summary
This document serves as a technical update on the progress of the GoTezos software library for Q4 (August-December). Although the project will still be maintained to the best of my ability this will be the final Tezos grant related update.
Improvements
The focus of quarter 4 has largely been around key management, local forging for script expressions (specifically used in Big Maps), RPC completion for Delphi and Edo, bug fixing, and improving the library design and structure.
Key Management
In the previous version of GoTezos (V3) only ed25519 (tz1) was supported as a key type. Go Tezos now supports importing keys, and signing for NistP256 (tz3) and secp256k1 (tz2). The keys package in GoTezos also experienced clean up and refactoring from GoTezos V3.
- ed25519: https://github.com/goat-systems/go-tezos/blob/master/keys/ed25519.go
- NistP256: https://github.com/goat-systems/go-tezos/blob/master/keys/nistP256.go
- secp256k1: https://github.com/goat-systems/go-tezos/blob/master/keys/secp256k1.go
Script Expression Forging
In addition to key management GoTezos now supports local forging for all script expressions. This allows you to query big_maps with any supported key type.
- Int Expression: https://github.com/goat-systems/go-tezos/blob/master/forge/forge.go#L1207
- Nat Expression: https://github.com/goat-systems/go-tezos/blob/master/forge/forge.go#L1217
- String Expression: https://github.com/goat-systems/go-tezos/blob/master/forge/forge.go#L1236
- Key Hash Expression: https://github.com/goat-systems/go-tezos/blob/master/forge/forge.go#L1246
- Address Expression: https://github.com/goat-systems/go-tezos/blob/master/forge/forge.go#L1262
- Bytes Expression: https://github.com/goat-systems/go-tezos/blob/master/forge/forge.go#L1277
- Micheline Expression: https://github.com/goat-systems/go-tezos/blob/master/forge/forge.go#L1288
RPC Completion
GoTezos now offers the complete list of protocol specific RPC’s for both Delphinet and Edonet. V4 also includes the removal of deprecated RPC’s.
New RPC’s added include:
- Contract Entrypoints : RPC/Code
- Contract Entrypoint: RPC/Code
- Contract Manager Key: RPC/Code
- Contract Script: RPC/Code
- Contract Single Sapling Diff: RPC/Code
- Delegate Deactivated: RPC/Code
- Delegate Grace Period: RPC/Code
- Delegate Voting Power: RPC/Code
- Block Nonces: RPC/Code
- Block Context Raw Bytes: RPC/Code
- Sapling Diff: RPC/Code
- Block Context Seed: RPC/Code
- Block Endorsing Power: RPC/Code
- Block Hash: RPC/Code
- Block Header: RPC/Code
- Block Header Protocol Data: RPC/Code
- Block Header Protocol Data Raw: RPC/Code
- Block Header Raw: RPC/Code
- Block Header Shell: RPC/Code
- Block Metadata: RPC/Code
- Block Metadata Hash: RPC/Code
- Block Minimal Valid Time: RPC/Code
- Operation Hashes: RPC/RPC/RPC/Code
- Operation Metadata Hashes: RPC/RPC/RPC/Code
- Operations: RPC/RPC/RPC/Code
- Operations Metadata Hash: RPC/Code
- Protocols: RPC/Code
- Required Endorsements: RPC/Code
- Complete Prefix: RPC/Code
- Current Level: RPC/Code
- Levels In Current Cycle: RPC/Code
- Parse Block: RPC/Code
- Parse Operations: RPC/Code
- Entrypoint: RPC/Code
- Entrypoints: RPC/Code
- Pack Data: RPC/Code
- Run Code: RPC/Code
- Trace Code: RPC/Code
- Type Check Code: RPC/Code
- Type Check Data: RPC/Code
Library Improvements
GoTezos went under construction again for V4 and now has some core library improvements.
HTTP Client
GoTezos improved the way it handles HTTP requests by leveraging the capabilities of the go-resty library. By leveraging this library GoTezos decouples some of the lower level http code and replaces it with a battle tested client packed with features that can make GoTezos easily extensible.
You can easily handle redirects, manage certificates, retries, add before/after middleware. While most of these features can be done with the core http client, which is what go-resty is built on, leveraging this library makes it simple for the user. GoTezos by default uses the default resty client but this can be overrode by using the OverrideClient function.
In addition to changing the http client, GoTezos now bubbles up the client responses with each HTTP request. As an example check out the Block function. You can see the function returns the *resty.Response
in the signature. This will allow users of GoTezos to better log and debug their applications at the network layer. You can see an example of how can use the resty.Response
type here.
Improved BlockIDs
Users of GoTezos may notice the Head
function is missing. This function used to get the head block. This is because GoTezos has pragmatically introduced BlockIDs. This allows users to write less code and identify blocks in a multitude of ways.
- Head BlockID: https://github.com/goat-systems/go-tezos/blob/master/rpc/block.go#L1630
- Level BlockID: https://github.com/goat-systems/go-tezos/blob/master/rpc/block.go#L1638
- Hash BlockID: https://github.com/goat-systems/go-tezos/blob/master/rpc/block.go#L1646
- Head Predecessor BlockID: https://github.com/goat-systems/go-tezos/blob/master/rpc/block.go#L1654
- Predecessor BlockID: https://github.com/goat-systems/go-tezos/blob/master/rpc/block.go#L1665
As an example on why this might be useful. In GoTezos V3 you would need to do something like this to fetch the current baking rights:
head, err := r.Head()if err != nil {// Do something with the error. Please.}bakingRights, err := r.BakingRights(BakingRightsInput{Blockhash: head.Hash})if err != nil {// Do something with the error. Please.}fmt.Println(bakingRights)
But with GoTezos V4 we can now skip a step:
resp, bakingRights, err := r.BakingRights(BakingRightsInput{BlockID: &rpc.BlockIDHead})if err != nil {// Do something with the error. Please.// Maybe checkout that response}fmt.Println(bakingRights)
Improved Documentation:
GoTezos V4 includes thorough in-code documentation. Each public type is documented with what the type is for as well as what RPC it is associated with it. Additionally each RPC function is documented with the path it will request, the RPC, as well as a description of what it does.

You can also use GoDoc to view the documentation generated from the code comments.
- Forge: https://pkg.go.dev/github.com/goat-systems/go-tezos/v4/forge
- Keys: https://pkg.go.dev/github.com/goat-systems/go-tezos/v4/keys
- RPC: https://pkg.go.dev/github.com/goat-systems/go-tezos/v4/rpc
The above links may not accurately reflect the current documentation because pkg.go.dev hasn’t indexed the latest tag. You can get the latest GoDoc by running
godoc -http:6060
Then visiting the following URLs:
- Forge: http://127.0.0.1:6060/pkg/github.com/goat-systems/go-tezos/v4/forge/
- Keys: http://127.0.0.1:6060/pkg/github.com/goat-systems/go-tezos/v4/keys/
- RPC: http://127.0.0.1:6060/pkg/github.com/goat-systems/go-tezos/v4/rpc/

Milestones

- Note: Missing
approve
andtransfer
entrypoints for FA1.2. I plan to add these post Grant as well as introduce functions for FA2. - V4 Changes: https://github.com/goat-systems/go-tezos/commit/519084001470cc6fb17c2d79010bec47da4489ff
Conclusion
I want to thank the Tezos Foundation and TQ Tezos for funding the development of this Library for 2020. It has been an amazing learning experience, lead to personal growth/career development, and opened up many opportunities beyond what the grant has provided.
Going forward I will not be asking or applying for any more funding around this project. I do plan to maintain it, respond to issues and pull requests, but will not be actively adding new features. That’s not to say that new features won’t be added from time to time. I will still actively be working on Tezos through camlCase, where I will be dedicating my time to smart contracts and functional programming with Haskell.