From bd7c7a28b9d6346cef09a210a9a52e794967c9ce Mon Sep 17 00:00:00 2001 From: Peter Harpending Date: Thu, 25 Sep 2025 22:35:55 -0700 Subject: [PATCH] talking to testnet node --- README.md | 30 +++++++++++++++++++++++++++++- gex_httpd/src/gex_httpd.erl | 18 ++++++++++++++++++ gex_httpd/zomp.meta | 13 ++++++++++++- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e89dfb2..0d87649 100644 --- a/README.md +++ b/README.md @@ -1032,7 +1032,9 @@ index 44d206d..3abd46f 100644 +slogan(500) -> "Internal Server Error". ``` -## Video 2: Talking to the gm testnet +## Video 2: Talking to the gm testnet (2025-09-25) + +- ### Adding hz as a dependency @@ -1040,3 +1042,29 @@ index 44d206d..3abd46f 100644 \[application\] (applications are the subset of what in another language you would call "libraries" that spawn processes, essentially...) for talking to the blockchain from an Erlang application. + +``` +$ zx list versions hakuzaru +0.6.1 +0.6.0 +0.5.2 +0.5.1 +0.5.0 +0.4.0 +0.3.2 +0.3.1 +0.3.0 +0.2.0 +0.1.0 +$ zx set dep otpr-hakuzaru-0.6.1 +``` + +If we just try to use this naively, we will run into errors whenever we try to +call code that calls into hz's dependencies. + +So we also have to manually include all of hz's dependencies. + +Thankfully, hz is also subject to this same constraint, so we only have to just +copy them from hz's zomp.meta file. + +### talking to testnet diff --git a/gex_httpd/src/gex_httpd.erl b/gex_httpd/src/gex_httpd.erl index 3a724b0..a2ed213 100644 --- a/gex_httpd/src/gex_httpd.erl +++ b/gex_httpd/src/gex_httpd.erl @@ -69,10 +69,28 @@ start() -> start(normal, _Args) -> Result = gh_sup:start_link(), % auto-listen to port 8000 + ok = hz(), ok = listen(8000), + ok = io:format("~p~n", [hz:status()]), Result. +hz() -> + ok = application:ensure_started(hakuzaru), + ok = hz:chain_nodes([testnet_node()]), + ok = zx:tell("hz status: ~tp", [hz:status()]), + ok. + +testnet_ip() -> + {84, 46, 242, 9}. + +testnet_port() -> + 3013. + +testnet_node() -> + {testnet_ip(), testnet_port()}. + + -spec stop(term()) -> ok. %% @private %% Similar to start/2 above, this is to be called by the "application" part of OTP, diff --git a/gex_httpd/zomp.meta b/gex_httpd/zomp.meta index 442e32e..eb32a14 100644 --- a/gex_httpd/zomp.meta +++ b/gex_httpd/zomp.meta @@ -5,7 +5,18 @@ {author,"Peter Harpending"}. {desc,"Gajumaru Exchange HTTP Daemon"}. {package_id,{"otpr","gex_httpd",{0,1,0}}}. -{deps,[{"otpr","hakuzaru",{0,6,1}},{"otpr","qhl",{0,1,0}}]}. +{deps,[ + {"otpr","hakuzaru",{0,6,1}}, + {"otpr","sophia",{9,0,0}}, + {"otpr","gmserialization",{0,1,3}}, + {"otpr","gmbytecode",{3,4,1}}, + {"otpr","base58",{0,1,1}}, + {"otpr","eblake2",{1,0,1}}, + {"otpr","ec_utils",{1,0,0}}, + {"otpr","zj",{1,1,0}}, + {"otpr","getopt",{1,0,2}}, + {"otpr","qhl",{0,1,0}} +]}. {key_name,none}. {a_email,"peterharpending@qpq.swiss"}. {c_email,"peterharpending@qpq.swiss"}.