-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.js
31 lines (23 loc) · 918 Bytes
/
compile.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
const solc = require('solc');
const path = require('path');
const fs = require('fs-extra');
const buildPath = path.resolve(__dirname, 'build');
fs.removeSync(buildPath);
const medicalRecordsSystemPath = path.resolve(__dirname, 'contracts', 'MedicalRecordsSystem.sol');
const medicalRecordSystemSource = fs.readFileSync(medicalRecordsSystemPath, 'utf8');
const medicalRecordPath = path.resolve(__dirname, 'contracts', 'MedicalRecord.sol');
const medicalRecordSource = fs.readFileSync(medicalRecordPath, 'utf8');
const input = {
sources: {
'MedicalRecordsSystem.sol': medicalRecordSystemSource,
'MedicalRecord.sol': medicalRecordSource
}
};
const output = solc.compile(input, 1).contracts;
fs.mkdirsSync(buildPath);
for (let contract in output) {
fs.outputJsonSync(
path.resolve(buildPath, contract.substring(contract.indexOf(':')+1,contract.length) + '.json'),
output[contract],
);
}