Class: EPM::Create
- Inherits:
-
Object
- Object
- EPM::Create
- Defined in:
- lib/epm/create.rb
Instance Method Summary collapse
- #deploy ⇒ Object
-
#initialize(file, settings = {}) ⇒ Create
constructor
A new instance of Create.
- #setup(settings) ⇒ Object
Constructor Details
#initialize(file, settings = {}) ⇒ Create
Returns a new instance of Create.
5 6 7 8 9 10 11 |
# File 'lib/epm/create.rb', line 5 def initialize file, settings={} if file @uri = URI.parse "http://localhost:#{settings['json-port']}" setup settings @contract = EPM::Compile.new(file, @settings).compile end end |
Instance Method Details
#deploy ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/epm/create.rb', line 13 def deploy if @settings['preferred-client'] == 'cpp' params = { 'sec' => @settings["address-private-key"], 'xEndowment' => '', 'bCode' => @contract, 'xGas' => '100000', 'xGasPrice' => ( @settings['gas-price'] || '100000000000000' ) } post_body = { 'method' => 'create', 'params' => params, 'id' => 'epm-rpc', "jsonrpc" => "2.0" }.to_json elsif @settings['preferred-client'] == ('go' || 'ethereal') params = { 'body' => @contract, 'value' => '', 'gas' => '100000', 'gasprice' => ( @settings['gas-price'] || '100000000000000' ) } post_body = { 'method' => 'EthereumApi.Create', 'params' => params, 'id' => 'epm-rpc', 'jsonrpc' => '2.0'}.to_json end return EPM::Server.http_post_request @uri, post_body end |