https://github.com/origintrail/dkg-hello-world
Minimal reference integration for DKG v10. Writes a greeting into Working Memory and reads it back via the node's public HTTP API — the smallest working end-to-end round trip, ~150 lines, zero dependencies. Fork as a starting template.
https://github.com/origintrail/dkg-hello-world
dkg example integration knowledge-graph origintrail template working-memory
Last synced: 2 months ago
JSON representation
Minimal reference integration for DKG v10. Writes a greeting into Working Memory and reads it back via the node's public HTTP API — the smallest working end-to-end round trip, ~150 lines, zero dependencies. Fork as a starting template.
- Host: GitHub
- URL: https://github.com/origintrail/dkg-hello-world
- Owner: OriginTrail
- License: apache-2.0
- Created: 2026-04-24T13:16:55.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-04-24T21:26:19.000Z (3 months ago)
- Last Synced: 2026-04-26T10:31:26.199Z (2 months ago)
- Topics: dkg, example, integration, knowledge-graph, origintrail, template, working-memory
- Language: JavaScript
- Homepage: https://github.com/OriginTrail/dkg-integrations
- Size: 16.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DKG Hello World
The minimal reference integration for the OriginTrail Decentralized Knowledge Graph v10.
This is the simplest possible integration that actually exercises a DKG node's memory model: it writes a greeting to Working Memory and reads it back, using nothing but the node's public HTTP API and Node.js's built-in `fetch`. Zero external dependencies, ~150 lines of code, one file.
Use it as a starting template for your own integration. Clone the repo, rename the package, replace the greeting logic with whatever you're actually building.
---
## Install
```bash
# Via the DKG integration registry (recommended)
dkg integration install dkg-hello-world
# Or directly from npm
npm install -g @origintrail-official/dkg-hello-world
```
You need a running DKG v10 node (`dkg start`). The integration picks up its auth token from `~/.dkg/auth.token` automatically, or from `DKG_AUTH_TOKEN` if you set it.
## Use
```bash
dkg-hello-world greet "first post from DKG Hello World"
# → ok · greeting "first post..." written to WM/dkg-hello-world/greetings
# https://origintrail.io/dkg-hello-world/greeting/1714000000000-abcd1234
dkg-hello-world greet "the DKG is up"
dkg-hello-world greet "agent integrations live here"
dkg-hello-world list
# 1. "first post from DKG Hello World"
# by did:dkg:agent:0x… at 2026-04-24T13:37:00.000Z
# https://origintrail.io/dkg-hello-world/greeting/…
# 2. "the DKG is up"
# 3. "agent integrations live here"
dkg-hello-world whoami
# → { "agentAddress": "0x…", "agentDid": "did:dkg:agent:0x…", … }
```
## What it does, step by step
1. **Loads the auth token.** From `DKG_AUTH_TOKEN` or `~/.dkg/auth.token`. No third-party credentials.
2. **Ensures a context graph named `dkg-hello-world` exists.** Calls `POST /api/context-graph/create`; treats `409 Conflict` as "already there" so re-running is idempotent.
3. **Ensures a Working Memory assertion named `greetings` exists** in that context graph.
4. **Writes four RDF triples per greeting** to that WM assertion via `POST /api/assertion/greetings/write`:
- the greeting's `rdf:type` → `dkg-hello-world:Greeting`
- `schema:description` → the message text
- `dcterms:created` → the current timestamp
- `dcterms:creator` → the DID of the calling agent (from `GET /api/agent/identity`)
5. **On `list`, reads those triples back** via `POST /api/assertion/greetings/query` and groups them by subject for display.
That's the whole integration. No SWM promotion, no VM publishing, no Curator-authority operations — just WM write + read, as a template.
## Extend it
To turn this into a real integration:
1. **Replace the greeting domain** with whatever you're modeling (Slack messages, GitHub issues, research notes, sensor readings).
2. **Promote matured assertions to Shared Memory** by adding a `POST /api/assertion/greetings/promote` call, so peers can see what you've written.
3. **Add a publish path** for assertions that should end up in Verified Memory, when your domain warrants it.
4. **Ship the integration's registry entry** to [`OriginTrail/dkg-integrations`](https://github.com/OriginTrail/dkg-integrations).
See [`DESIGN.md`](DESIGN.md) for the full design brief.
## License
Apache-2.0. See [LICENSE](LICENSE).