Class: Etherlite::Connection
- Inherits:
-
Object
- Object
- Etherlite::Connection
- Includes:
- Api::Rpc
- Defined in:
- lib/etherlite/connection.rb
Instance Attribute Summary collapse
-
#chain_id ⇒ Object
readonly
Returns the value of attribute chain_id.
Instance Method Summary collapse
-
#initialize(_uri, _chain_id = nil) ⇒ Connection
constructor
A new instance of Connection.
- #ipc_call(_method, *_params) ⇒ Object
Methods included from Api::Rpc
#eth_block_number, #eth_call, #eth_gas_price, #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, _chain_id = nil) ⇒ Connection
Returns a new instance of Connection.
7 8 9 10 |
# File 'lib/etherlite/connection.rb', line 7 def initialize(_uri, _chain_id = nil) @uri = _uri @chain_id = _chain_id end |
Instance Attribute Details
#chain_id ⇒ Object (readonly)
Returns the value of attribute chain_id.
5 6 7 |
# File 'lib/etherlite/connection.rb', line 5 def chain_id @chain_id end |
Instance Method Details
#ipc_call(_method, *_params) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/etherlite/connection.rb', line 12 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 |