-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
50 lines (42 loc) · 1.45 KB
/
server.js
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
44
45
46
47
48
49
50
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const axios = require('axios');
const { agent } = require('./agent');
const app = express();
const did = 'did:ethr:rinkeby:0x8db769ae3866186bd4ff280a1db94ce2a85a90d9';
app.use(cors());
app.use(bodyParser.json());
async function apiCall() {
try {
// const identity = await agent.identityManagerCreateIdentity({
// alias: 'bob2',
// provider: 'did:ethr:rinkeby',
// kms: 'local'
// });
// console.log(identity.did);
console.log('***************************************************************');
const result = await agent.identityManagerAddService({
did: did,
service: {
id: did,
type: 'import identity',
serviceEndpoint: 'http://localhost:3001/agent',
},
options: {
gas: 1000001
},
});
console.log(result);
console.log('***************************************************************');
const response = await axios.post('http://localhost:3001/agent/did', {
did: did
});
console.log(response.data);
// const importIdentity = await agent.identityManagerImportIdentity({ did: identity.did });
// console.log(importIdentity);
} catch (error) {
console.log(error);
}
}
apiCall();