-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (35 loc) · 1.2 KB
/
index.js
File metadata and controls
43 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//Use 'ethjs-provider-http' instead of 'web3' due to this issue: https://github.com/uport-project/ethr-did/issues/3#issuecomment-413908925
const HttpProvider = require('ethjs-provider-http')
let provider = new HttpProvider('https://rinkeby.infura.io')
const resolve = require('did-resolver').default;
const registerEthrDidToResolver = require('ethr-did-resolver').default
const EthrDID = require('ethr-did');
let test = async () => {
//Registery address for ethr did
let registryAddress = '0xdCa7EF03e98e0DC2B855bE647C39ABe984fcF21B'
//Generating Eth keyPair
const keypair = EthrDID.createKeyPair()
//Generating Ethr DID
const ethrDid = new EthrDID({
...keypair,
provider,
registry: registryAddress
})
console.log('Ethr DID\n\n', ethrDid)
let did = ethrDid.did
//Registering Ethr Did To Resolver
registerEthrDidToResolver({
provider,
registry: registryAddress,
})
//Resolving Ethr DID to DID document
resolve(did)
.then(didDocument => {
console.log('\n\nEthr DID Document\n\n')
console.dir(didDocument)
})
.catch(error => {
console.error(error)
})
}
test()