Skip to main content

C++ — raw HTTP

Call ZeqVM from C++

C++ 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 libcurl snippet below wraps exactly this wire format.

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 — libcurl

C++ has no standard HTTP client; libcurl is the de-facto standard and ships on every platform. Compile-ready:

// g++ -std=c++17 zeq_compute.cpp -lcurl && ZEQ_API_KEY=... ./a.out
#include <curl/curl.h>
#include <cstdlib>
#include <iostream>
#include <string>

static size_t collect(char* p, size_t s, size_t n, void* out) {
static_cast<std::string*>(out)->append(p, s * n);
return s * n;
}

int main() {
const char* key = std::getenv("ZEQ_API_KEY");
const std::string body =
R"({ "operators": ["KO42", "NM19"], "domain": "Newtonian Mechanics", "inputs": { "mass": 5, "acceleration": 9.81 } })";
std::string resp;

CURL* curl = curl_easy_init();
if (!curl) return 1;

curl_slist* hdrs = nullptr;
hdrs = curl_slist_append(hdrs,
("Authorization: Bearer " + std::string(key ? key : "")).c_str());
hdrs = curl_slist_append(hdrs, "Content-Type: application/json");

curl_easy_setopt(curl, CURLOPT_URL, "https://zeqsdk.com/api/zeq/compute");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, hdrs);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, collect);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &resp);

const CURLcode rc = curl_easy_perform(curl);
curl_slist_free_all(hdrs);
curl_easy_cleanup(curl);

if (rc != CURLE_OK) { std::cerr << curl_easy_strerror(rc) << "\n"; return 1; }
std::cout << resp << "\n"; // full envelope: value, unit, signed, compliance, zeqProof …
return 0;
}

Parse with nlohmann::json or any JSON library — the envelope is plain JSON. The public pulse needs no key: GET https://zeqsdk.com/api/zeq/pulse.

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 C++ here

  • Industrial control systems. Compose against the same entangled state that an Embedded C observer agent writes to. Both speak the same JSON wire contract.
  • Game engines and physics. A long-running game-engine worker can post a compute every frame; the HulyaPulse 1.287 Hz tick aligns naturally with the engine's frame budget.
  • Low-latency desks. The same compute envelope SOX/SOC 2 auditors already trust, from the language your hot path is written in.

Compose with

Source