class Eth::Solidity
def compile(contract)
-
(Array)
- JSON containing the compiled contract and ABI for all contracts.
Parameters:
-
contract
(String
) -- path of the contract to compile.
def compile(contract) raise Errno::ENOENT, "Contract file not found: #{contract}" unless File.exist? contract flag_opt = "--optimize" flag_json = "--combined-json=bin,abi" path = File.realpath contract output, error, status = Open3.capture3 @compiler, flag_opt, flag_json, path raise SystemCallError, "Unable to run solc compiler!" if status.exitstatus === 127 raise CompilerError, error unless status.success? json = JSON.parse output result = {} json["contracts"].each do |key, value| _file, name = key.split ":" result[name] = {} result[name]["abi"] = value["abi"] result[name]["bin"] = value["bin"] end return result end