Method: Zapper::Client#balances

Defined in:
lib/zapper.rb

#balances(address) ⇒ Faraday::Response

Returns all apps Zapper knows about. If an id is provided, it will return information on just that app.

Parameters:

  • address (String)

    The hexidecimal address you want to query.

Returns:

  • (Faraday::Response)


45
46
47
48
49
50
51
52
53
54
55
# File 'lib/zapper.rb', line 45

def balances(address)
  response = conn.get("/v2/balances") do |req|
    req.params["addresses[]"] = address
  end
  response.env.response_body = response
                               .body
                               .split("event: ")
                               .map { |x| x.split("balance\ndata: ")[1] }
                               .compact.map { |x| JSON.parse(x) }
  response
end