eth DID Resolver
This library is intended to use ethereum addresses as Decentralized Identifiers and wrap them in a DID Dcument
It supports the proposed Decentralized Identifiers spec from the W3C Credentials Community Group.
It requires the did-resolver
library, which is the primary interface for resolving DIDs.
DID method
To encode a DID for an Ethereum address, simply prepend did:eth:
eg:
did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74
DID Document
The did resolver takes the ethereum address and wraps it into a simple DID document:
'@context': 'https://w3id.org/did/v1' id:'did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74' publicKey: id: `did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74#keys-1` type: 'Secp256k1VerificationKey2018' owner: 'did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74' ethereumAddress: '0xf3beac30c498d9e26865f34fcaa57dbb935b0d74'
Note this uses the Secp256k1VerificationKey2018
type and an ethereumAddress
instead of a publicKeyHex
.
Resolving a DID document
The resolver presents a simple resolver()
function that returns a ES6 Promise returning the DID document.
// You can also use ES7 async/await syntaxconst doc = await