-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.js
38 lines (34 loc) · 1.01 KB
/
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
38
const path = require("path");
const fs = require("fs");
const solc = require("solc");
const util = require('util')
const lotteryPath = path.resolve(__dirname, "contracts", "Lottery.sol");
const source = fs.readFileSync(lotteryPath, "utf8");
let compilerInput = {
language: 'Solidity',
sources:
{
'Lottery.sol':
{
content: source
}
},
settings:
{
optimizer:
{
enabled: true
},
outputSelection:
{
'*':{
'*':['*']
}
}
}
};
let compiledContract = JSON.parse(solc.compile(JSON.stringify(compilerInput)));
//console.log(JSON.stringify(compiledContract, null, 4))
//console.log(util.inspect(compiledContract['contracts']['Lottery.sol']['Lottery']['abi'], {depth: null}))
//console.log(compiledContract['contracts']['Lottery.sol']['Lottery']['evm']['bytecode'])
module.exports = JSON.parse(JSON.stringify(compiledContract['contracts']['Lottery.sol']['Lottery'], null, 4));