Skip to content
This repository has been archived by the owner. It is now read-only.
DID resolver for Ethereum Addresses
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.babelrc
.gitignore
LICENSE initial commit of eth-did-resolver Feb 25, 2018
README.md
package.json
yarn.lock

README.md

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.

import resolve from 'did-resolver'
import registerResolver from 'eth-did-resolver'

registerResolver()

resolve('did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74').then(doc => console.log)

// You can also use ES7 async/await syntax
const doc = await resolve('did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74')
You can’t perform that action at this time.