DID Method Registration via JSON

This guide explains how to register DID methods using JSON files that follow the DID Registration specification. This makes it easy to add support for new DID methods without writing code.

Quick Start

1. Create a JSON Registration File

Create a JSON file in src/main/resources/did-methods/ (or any directory) using the official DID Method Registry format:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
  "name": "example",
  "status": "implemented",
  "specification": "https://example.com/did-method-spec",
  "contact": {
    "name": "Example Team",
    "email": "contact@example.com"
  },
  "implementations": [
    {
      "name": "Universal Resolver",
      "driverUrl": "https://dev.uniresolver.io",
      "testNet": false
    }
  ]
}

This format matches the official DID Method Registry structure from https://identity.foundation/did-registration/, making it easy to use registry entries directly.

2. Load and Register the Method

1
2
3
4
5
6
7
8
9
10
11
12
13
import org.trustweave.did.registrar.method.JsonDidMethodLoader
import org.trustweave.did.registry.DidMethodRegistry
import java.nio.file.Paths

val loader = JsonDidMethodLoader()
val registry = DidMethodRegistry()

// Load from file
val method = loader.loadFromFile(Paths.get("src/main/resources/did-methods/example.json"))
registry.register(method)

// Or load every JSON file under a classpath resource folder (e.g. resources/did-methods/)
loader.loadFromClasspath("did-methods").forEach { registry.register(it) }

3. Use the Registered Method

1
2
3
val resolver = RegistryBasedResolver(registry)
val did = Did("did:example:123")
val result = resolver.resolve(did)

JSON Specification

See DID Method Registration JSON Specification for complete details on the JSON format and mapping.

Quick Reference

See DID Method Registration Quick Reference for a concise reference guide.


This site uses Just the Docs, a documentation theme for Jekyll.