-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile.js
More file actions
27 lines (21 loc) · 888 Bytes
/
Copy pathcompile.js
File metadata and controls
27 lines (21 loc) · 888 Bytes
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
const fs = require('fs');
const solc = require('solc');
console.log('Compiling DripFeed.sol...');
const source = fs.readFileSync('DripFeed.sol', 'utf8');
const input = {
language: 'Solidity',
sources: { 'DripFeed.sol': { content: source } },
settings: { outputSelection: { '*': { '*': ['abi', 'evm.bytecode'] } } }
};
const output = JSON.parse(solc.compile(JSON.stringify(input)));
if (output.errors) {
const errors = output.errors.filter(e => e.severity === 'error');
if (errors.length > 0) {
errors.forEach(e => console.error(e.message));
process.exit(1);
}
}
const contract = output.contracts['DripFeed.sol']['DripFeed'];
fs.writeFileSync('DripFeed_abi.json', JSON.stringify(contract.abi, null, 2));
fs.writeFileSync('DripFeed_bytecode.json', JSON.stringify({ bytecode: '0x' + contract.evm.bytecode.object }, null, 2));
console.log('Compiled successfully!');