-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.js
37 lines (32 loc) · 871 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
32
33
34
35
36
37
// compile code will go here
// command: node compile.js
const path = require('path');
const fs = require('fs');
const solc = require('solc');
const lotteryPath = path.resolve(__dirname, 'contracts', 'lottery.sol');
const source = fs.readFileSync(lotteryPath, 'utf8');
// define the input in json based on:
// https://docs.soliditylang.org/en/v0.8.7/using-the-compiler.html#compiler-input-and-output-json-description
const input = {
language: 'Solidity',
sources: {
'lottery.sol': {
content: source,
},
},
settings: {
outputSelection: {
'*': {
'*': ['*'],
},
},
},
};
// var parsedJson = JSON.parse(solc.compile(JSON.stringify(input))).contracts[
// 'lottery.sol'
// ].Lottery;
//
// console.log(parsedJson);
module.exports = JSON.parse(solc.compile(JSON.stringify(input))).contracts[
'lottery.sol'
].Lottery;