Skip to main content
European CommissionEBSI European Blockchain

Legal Entity DID Resolver

The @cef-ebsi/ebsi-did-resolver library supports the did:ebsi method.

In order to resolve DID documents, the EBSI DID resolver requires the did-resolver library, which is the primary interface for resolving DIDs.

Installation

npm install @cef-ebsi/ebsi-did-resolver

or if you use yarn:

yarn add @cef-ebsi/ebsi-did-resolver

Resolving a DID document

The library provides a resolver that is meant to be used through the did-resolver aggregator.

import { Resolver } from "did-resolver";
import { getResolver } from "@cef-ebsi/ebsi-did-resolver";

// You must set the address of the DID Registry to be used in order to resolve Legal Entities DID documents
const resolverConfig = {
registry: "https://api-pilot.ebsi.eu/did-registry/v4/identifiers",
};

// getResolver will return an object with a key/value pair of { "ebsi": resolver } where resolver is a function used by the generic DID resolver.
const ebsiResolver = getResolver(resolverConfig);
const didResolver = new Resolver(ebsiResolver);

didResolver
.resolve("did:ebsi:zub5ZZUfHLLptCduwEy8xRj")
.then((doc) => console.log);

// You can also use ES7 async/await syntax
const doc = await didResolver.resolve("did:ebsi:zub5ZZUfHLLptCduwEy8xRj");

Creating a DID

The library exposes a method allowing you to create a DID from the given subject identifier bytes:

import { util } from "@cef-ebsi/ebsi-did-resolver";
import { randomBytes } from "node:crypto";

const subjectIdentifierBytes = randomBytes(16); // An array of 16 random bytes
const did = util.createDid(subjectIdentifierBytes);
// Example: "did:ebsi:ztRBFfMCY7VAGHH1Ba8Q5o9"

Try it online

Paste a DID or .

info

The DID document is loaded from the DID Registry. Read DID Method for Legal Entities for more information.