Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
blockscout/apps/explorer/priv/compile_solc.js

50 lines
1.1 KiB

#!/usr/bin/env node
var sourceCodePath = process.argv[2];
var compilerVersionPath = process.argv[3];
var optimize = process.argv[4];
var optimizationRuns = parseInt(process.argv[5], 10);
var newContractName = process.argv[6];
var externalLibraries = JSON.parse(process.argv[7])
var evmVersion = process.argv[8];
var solc = require('solc')
var compilerSnapshot = require(compilerVersionPath);
var solc = solc.setupMethods(compilerSnapshot);
var fs = require('fs');
var sourceCode = fs.readFileSync(sourceCodePath, 'utf8');
var settings = {
optimizer: {
enabled: optimize == '1',
runs: optimizationRuns
},
libraries: {
[newContractName]: externalLibraries
},
outputSelection: {
'*': {
'*': ['*']
}
}
}
if (evmVersion !== 'default') {
settings = Object.assign(settings, {evmVersion: evmVersion})
}
const input = {
language: 'Solidity',
sources: {
[newContractName]: {
content: sourceCode
}
},
settings: settings
}
const output = JSON.parse(solc.compile(JSON.stringify(input)))
console.log(JSON.stringify(output));