Skip to content

Commit fe25946

Browse files
committed
Added value key in deploy
1 parent 1ed1f1f commit fe25946

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

solc_helper

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require 'json'
44

55
def library_code
6-
'function create(abiDefinition) { return web3.eth.contract(abiDefinition);}function deploy(account, gas, contract, code, input) { if (typeof(input)===\'undefined\') input = null; 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); } } else { console.log(e) } }); return instance;}function watcher(error, result) { if (!error) { console.log("Result"); console.log(JSON.stringify(result)); return; } console.log("Error" + error);}function call(account, gas, func, input) { if (typeof(input)===\'undefined\') input = null; func.sendTransaction(input, gas, {from:account}, watcher);}'
6+
'function create(abiDefinition) { return web3.eth.contract(abiDefinition);}function deploy(account, value, gas, contract, code, input) { if (typeof(input)===\'undefined\') input = null; var instance = contract.new(input,{from:account, value: value, 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); } } else { console.log(e) } }); return instance;}function watcher(error, result) { if (!error) { console.log("Result"); console.log(JSON.stringify(result)); return; } console.log("Error" + error);}function call(account, gas, func, input) { if (typeof(input)===\'undefined\') input = null; func.sendTransaction(input, gas, {from:account}, watcher);}'
77
end
88

99

@@ -51,6 +51,15 @@ def get_gas
5151
gas
5252
end
5353

54+
def get_value
55+
gas = -1
56+
while gas < 0
57+
puts "Enter Value To Be Transferred: "
58+
gas = $stdin.gets.to_i
59+
end
60+
gas
61+
end
62+
5463
file_name = ARGV[0]
5564
code = File.read(file_name).gsub("\n",'')
5665

@@ -64,15 +73,18 @@ contract_variable_name = "#{current_contract}Contract"
6473
contract_instance_variable_name = "#{current_contract}"
6574

6675
gas = get_gas
76+
value = get_value
6777
input = get_input
6878

6979
File.open(javascript_file_name, 'w') do |f|
7080
f.write("#{library_code};\nvar #{compiled_variable_name} = #{compiled_object.to_json};")
7181
f.write("#{contract_variable_name} = create(#{compiled_variable_name}.#{current_contract}.info.abiDefinition);")
72-
f.write("#{contract_instance_variable_name} = deploy(eth.coinbase,#{gas},#{contract_variable_name},#{compiled_variable_name}.#{current_contract}.code,#{input});")
82+
f.write("#{contract_instance_variable_name} = deploy(eth.coinbase,#{value},#{gas},#{contract_variable_name},#{compiled_variable_name}.#{current_contract}.code,#{input});")
7383
f.write("console.log('Compiled Object : #{compiled_variable_name}');")
7484
f.write("console.log('Contract : #{contract_variable_name}');")
7585
f.write("console.log('Contract Instance : #{contract_instance_variable_name}');")
7686
end
7787

7888
puts "loadScript('#{`pwd`}/#{javascript_file_name}')".gsub("\n",'')
89+
# ~> -:64:in `read': no implicit conversion of nil into String (TypeError)
90+
# ~> from -:64:in `<main>'

0 commit comments

Comments
 (0)