Class: Zilliqa::Jsonrpc::Provider
- Inherits:
-
Object
- Object
- Zilliqa::Jsonrpc::Provider
- Defined in:
- lib/zilliqa/jsonrpc/provider.rb
Instance Method Summary collapse
- #GetBalance(*args) ⇒ Object
-
#initialize(endpoint) ⇒ Provider
constructor
A new instance of Provider.
- #method_missing(sym, *args) ⇒ Object
Constructor Details
#initialize(endpoint) ⇒ Provider
Returns a new instance of Provider.
15 16 17 18 19 20 21 |
# File 'lib/zilliqa/jsonrpc/provider.rb', line 15 def initialize(endpoint) conn = Faraday.new { |connection| connection.adapter Faraday.default_adapter } @client = JSONRPC::Client.new(endpoint, { connection: conn }) @endpoint = endpoint end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
28 29 30 |
# File 'lib/zilliqa/jsonrpc/provider.rb', line 28 def method_missing(sym, *args) @client.invoke(sym.to_s, args) end |
Instance Method Details
#GetBalance(*args) ⇒ Object
23 24 25 26 |
# File 'lib/zilliqa/jsonrpc/provider.rb', line 23 def GetBalance(*args) formatted = args.map { |addr| Util::Bech32.to_checksum_address(addr).downcase.sub('0x', '') } @client.invoke('GetBalance', formatted) end |