Class: Etherlite::Connection
- Inherits:
-
Object
- Object
- Etherlite::Connection
- Includes:
- Api::ParityRpc, Api::Rpc
- Defined in:
- lib/etherlite/connection.rb
Instance Attribute Summary collapse
-
#chain_id ⇒ Object
readonly
Returns the value of attribute chain_id.
-
#use_parity ⇒ Object
readonly
Returns the value of attribute use_parity.
Instance Method Summary collapse
-
#initialize(_uri, _options = {}) ⇒ Connection
constructor
A new instance of Connection.
- #ipc_call(_method, *_params) ⇒ Object
Methods included from Api::ParityRpc
Methods included from Api::Rpc
#eth_block_number, #eth_call, #eth_gas_price, #eth_get_balance, #eth_get_transaction_by_hash, #eth_get_transaction_count, #eth_get_transaction_receipt, #eth_send_raw_transaction, #eth_send_transaction, #evm_increase_time, #evm_mine, #evm_revert, #evm_snapshot, #personal_send_transaction
Constructor Details
#initialize(_uri, _options = {}) ⇒ Connection
Returns a new instance of Connection.
8 9 10 11 12 |
# File 'lib/etherlite/connection.rb', line 8 def initialize(_uri, = {}) @uri = _uri @chain_id = [:chain_id] @use_parity = [:use_parity] end |
Instance Attribute Details
#chain_id ⇒ Object (readonly)
Returns the value of attribute chain_id.
6 7 8 |
# File 'lib/etherlite/connection.rb', line 6 def chain_id @chain_id end |
#use_parity ⇒ Object (readonly)
Returns the value of attribute use_parity.
6 7 8 |
# File 'lib/etherlite/connection.rb', line 6 def use_parity @use_parity end |
Instance Method Details
#ipc_call(_method, *_params) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/etherlite/connection.rb', line 14 def ipc_call(_method, *_params) id = new_unique_id payload = { jsonrpc: "2.0", method: _method, params: _params, id: id } # TODO: support ipc Net::HTTP.start(@uri.hostname, @uri.port, use_ssl: use_ssl?) do |http| return handle_response http.post( @uri.path.empty? ? '/' : @uri.path, payload.to_json, "Content-Type" => "application/json" ), id end end |