-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateConsent.js
34 lines (25 loc) · 1.04 KB
/
updateConsent.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
'use strict';
const {FileSystemWallet, Gateway} = require('fabric-network');
const fs = require('fs');
const path = require('path');
async function main(args) {
try {
const ccpPath = path.resolve(__dirname, 'connection.json');
const ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8'));
const walletPath = path.resolve(__dirname, 'wallet');
const wallet = new FileSystemWallet(walletPath);
const gateway = new Gateway();
await gateway.connect(ccp, {wallet, identity: args[0], discovery: {enabled: true, asLocalhost: false}});
const network = await gateway.getNetwork('channel2');
const contract = network.getContract('consentio');
await contract.submitTransaction("updateConsent",
args[1], "g", "all", args[2], "20160101", "101", "hippa"
);
await gateway.disconnect();
} catch (error) {
console.error(`Failed to submit transaction: ${error}`);
process.exit(1);
}
}
// args: [user, identity, start_date]
main(process.argv.slice(2));