-
Notifications
You must be signed in to change notification settings - Fork 108
/
optimize.js
41 lines (36 loc) · 994 Bytes
/
optimize.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
39
40
41
const fs = require('fs').promises;
const solc = require('solc');
async function process (contractName) {
const content = await fs.readFile(contractName + '.full.sol', 'utf-8');
const sources = {};
sources[contractName] = {
content: content,
};
const input = {
language: 'Solidity',
sources,
settings: {
outputSelection: {
'*': {
'*': ['*'],
},
},
optimizer: {
enabled: true,
runs: 1000000,
},
},
};
const output = JSON.parse(solc.compile(JSON.stringify(input)));
await fs.writeFile(
contractName + '.full.opt.bin',
output.contracts[contractName][contractName].evm.bytecode.object,
'utf-8',
);
}
(async function () {
const contractNames = [
'OneInch',
];
await Promise.all(contractNames.map(contractName => process(contractName)));
})();