Skip to main content

Go — raw HTTP

Call ZeqVM from Go

Go reaches ZeqVM through three surfaces: the terminal CLI (/cli/), raw HTTP (the wire format below — what every client wraps), and zeq.py (Python — a single file, fetched from any node). The net/http snippet below is zero-dependency and compile-ready.

Get the CLI (recommended first install)

Every node serves the terminal CLI with a sha256-pinned installer — the fastest way onto the framework:

curl -fsSL https://zeqstate.com/install.sh | sh # any node works as the origin
zeq tutorial # guided: account → machine → first compute → verify

Full install notes + the complete command reference: /cli/.

Compute over raw HTTP — stdlib only

Zero external dependencies — net/http + encoding/json. Compile-ready:

package main

import (
"bytes"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"os"
)

func main() {
body, _ := json.Marshal(map[string]any{
"operators": []string{"KO42", "NM19"},
"domain": "Newtonian Mechanics",
"inputs": map[string]any{"mass": 5, "acceleration": 9.81},
})
req, _ := http.NewRequest("POST", "https://zeqsdk.com/api/zeq/compute", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("ZEQ_API_KEY"))
req.Header.Set("Content-Type", "application/json")

res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()

raw, _ := io.ReadAll(res.Body)
var out map[string]any
json.Unmarshal(raw, &out)
fmt.Println(out["value"], out["unit"], out["uncertainty"])
fmt.Println("zeqProof:", out["zeqProof"])
fmt.Println("explorer:", out["explorer_url"])
}

The public pulse needs no key: GET https://zeqsdk.com/api/zeq/pulse with the same stdlib pattern.

The response's compliance field is the ZeqCompliance v1 envelope — the 13-standard regulatory record returned on every call. Every result also carries signed — an Ed25519-signed claim (claim + signature + public_key) verifiable offline by anyone, or by POSTing the block to any node's public /api/attest. Or pipe the whole envelope to the CLI: … | zeq verify -.

Why Go here

  • Backend services. Drop the snippet into a cmd/ binary and you have a compute worker that scales horizontally without any extra glue.
  • CLI tools. Single static binary, fast cold-start, no runtime to ship.
  • Goroutine concurrency. Wrap the request in context.Context; cancel an in-flight compute cleanly when the caller's request is closed.

Compose with

Source