Skip to content

Commit b5b6b7c

Browse files
committed
first commit
0 parents  commit b5b6b7c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# solidity_compiler_helper

solc_compiler

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'json'
4+
5+
library_code = 'function createContract(abiDefinition) { return web3.eth.contract(abiDefinition);}function getContractInstance(contract, input, account, code, gas) { var instance = contract.new(input,{from:account, data: code, gas: gas}, function (e, contract) { if(!e) { if(!contract.address) { console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined..."); } else { console.log("Contract mined! Address: " + contract.address); console.log(contract); } } else { console.log(e) } }); return instance;}
6+
'
7+
file_name = ARGV[0]
8+
code = File.read(file_name).gsub("\n",'')
9+
10+
json_string= `curl -s -X POST --data '{"jsonrpc":"2.0","method":"eth_compileSolidity","params":["#{code}"],"id":1}' http://127.0.0.1:8100`
11+
12+
json_object = JSON.parse(json_string)
13+
compiled_object = json_object['result'].to_json
14+
javascript_file_name = file_name.split('.')[0] + '_compiled.js'
15+
16+
File.open(javascript_file_name, 'w') do |f|
17+
f.write("#{library_code};\nvar compiled = #{compiled_object};")
18+
end
19+
puts "loadScript('#{`pwd`}/#{javascript_file_name}')".gsub("\n",'')

0 commit comments

Comments
 (0)