-
Notifications
You must be signed in to change notification settings - Fork 522
/
Copy pathcreateWallet.js
38 lines (31 loc) · 1.01 KB
/
createWallet.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
"use strict";
const fs = require('fs');
const path = require('path');
const {common: commonProto} = require('fabric-protos');
const {Wallets} = require('fabric-network');
const mspId = 'Org1MSP';
const baseMSPPath = '../crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp'
const signCertPath = path.resolve(baseMSPPath + '/signcerts/[email protected]');
const signKeyPath = path.resolve(baseMSPPath + '/keystore/priv_sk');
const signCert = fs.readFileSync(signCertPath).toString();
const signKey = fs.readFileSync(signKeyPath).toString();
/**
* Main entrance method
* @returns {Promise<*>}
*/
const main = async () => {
const wallet = await Wallets.newFileSystemWallet('/opt/test/wallet');
const x509Identity = {
credentials: {
certificate: signCert,
privateKey: signKey,
},
mspId: mspId,
type: 'X.509',
};
await wallet.put(mspId + '-admin', x509Identity);
return "wallet is created"
};
main()
.then(console.log)
.catch(console.error);