So I’m an absolute noob and I’m trying to call a simple hello-world app from the browser.
I put together this code pen which basically does the following:
import { connect } from "https://cdn.skypack.dev/@holochain/hc-web-client@0.5.3";
const { callZome, onSignal, close } = await connect({
url: "ws://localhost:41141",
});
const result = await callZome("test-app", "whoami", "whoami")({
"arg": "value",
});
console.log(result);
close();
Then I run a sandbox locally, like so:
$ nix-shell https://nightly.holochain.love
[nix-shell:~]$ git clone git@github.com:holochain/holochain-dna-build-tutorial
[nix-shell:~]$ cd holochain-dna-build-tutorial/workdir/dna
[nix-shell:~/holochain-dna-build-tutorial/workdir/dna]$ hc sandbox create
hc-sandbox: Creating 1 conductor sandboxes with same settings
[…]
[nix-shell:~/holochain-dna-build-tutorial/workdir/dna]$ hc sandbox list
hc-sandbox:
Sandboxes contained in `.hc`
0: /tmp/tmp.bFPCTdnwBX/jQMNS4PUfFBYOWQ1DWCM-
[nix-shell:~/holochain-dna-build-tutorial/workdir/dna]$ hc sandbox run -l
Conductor ready.
hc-sandbox: Running conductor on admin port 41141
hc-sandbox: Connected successfully to a running holochain
The WebSocket client can connect to the sandbox, but it is unclear to me what should be the first argument to callZome(…)
. The documentation on https://github.com/holochain/hc-web-client suggests it is the “instance ID” but I don’t know how should I get my instance ID, or how this would even work in practice.
For a browser application, ideally I’d like to load all assets as well through the websocket connection (I guess I’d package those into some static DNA?).
Another question: I’m actually connecting to the admin interface, which doesn’t sound like something I’d want to expose to the internet. How do I set up a network interface (e.g. a websocket port) that I can use but that does not give admin access to the sandbox?
Here is the auto-generated conductor-config.yaml
:
---
environment_path: /tmp/tmp.bFPCTdnwBX/jQMNS4PUfFBYOWQ1DWCM-
use_dangerous_test_keystore: false
signing_service_uri: ~
encryption_service_uri: ~
decryption_service_uri: ~
dpki: ~
keystore_path: /tmp/tmp.bFPCTdnwBX/jQMNS4PUfFBYOWQ1DWCM-/keystore
passphrase_service: ~
admin_interfaces:
- driver:
type: websocket
port: 0
network: ~
I have a feeling I’m missing something very obvious here. I might have skipped some important part of the tutorial — I was eager to put together an end-to-end hello-world
Thanks for helping.