-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLED_token_on_hyperledger
39 lines (29 loc) · 1.17 KB
/
LED_token_on_hyperledger
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
'use strict';
const { Contract } = require('fabric-network');
const path = require('path');
async function main() {
try {
// Create a new contract
const contract = new Contract('led-token');
// Set the network to use
const network = await contract.getNetwork('mychannel');
// Get the contract from the network
const contract = network.getContract('led-token');
// Set the total supply of LED coins
await contract.submitTransaction('initLedChain', '8000000000');
// Set the identity of a user
await contract.submitTransaction('setIdentity', 'user1', 'John Smith', '123 Main St.', '12345');
// Get the identity of a user
const identity = await contract.evaluateTransaction('getIdentity', 'user1');
console.log(identity);
// Set the health data of a user
await contract.submitTransaction('setHealthData', 'user1', 'Blood Pressure', '120/80');
// Get the health data of a user
const healthData = await contract.evaluateTransaction('getHealthData', 'user1', 'Blood Pressure');
console.log(healthData);
} catch (error) {
console.error(`Error interacting with LED Token: ${error}`);
process.exit(1);
}
}
main();