Module: Elrond::Api::Wallet::Endpoints::Address

Included in:
Client
Defined in:
lib/elrond/api/wallet/endpoints/address.rb

Instance Method Summary collapse

Instance Method Details

#address(address, options: {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/elrond/api/wallet/endpoints/address.rb', line 7

def address(address, options: {})
  data          =   nil
  response      =   get("/address/#{address}", options: options)&.body
  
  if response && response.is_a?(Hash)
    response    =   response&.fetch("account", {})
    nonce       =   response.fetch("nonce", nil)
    balance     =   response.fetch("balance", nil)
    balance     =   !balance.to_s.empty? ? (balance.to_f / 10_000.0) : nil
    
    data        =   {
      address: address,
      nonce:   nonce,
      balance: balance
    }
  end
  
  return data            
end