Method: Eth::Client.create

Defined in:
lib/eth/client.rb

.create(host) ⇒ Eth::Client::Ipc, ...

Creates a new RPC-Client, either by providing an HTTP/S host, WS/S host, or an IPC path. Supports basic authentication with username and password.

Note, this sets the folling gas defaults: Tx::DEFAULT_PRIORITY_FEE and Use {#max_priority_fee_per_gas and #max_fee_per_gas to set custom values prior to submitting transactions.

Raises:

  • (ArgumentError)

    in case it cannot determine the client type.



70
71
72
73
74
75
# File 'lib/eth/client.rb', line 70

def self.create(host)
  return Client::Ipc.new host if host.end_with? ".ipc"
  return Client::Http.new host if host.start_with? "http"
  return Client::Ws.new host if host.start_with? "ws"
  raise ArgumentError, "Unable to detect client type!"
end