Skip to content

OriginTrail/dkg-hello-world

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

# 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

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:typedkg-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.

See DESIGN.md for the full design brief.

License

Apache-2.0. See LICENSE.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors