Class: Eost::Eosscan

Inherits:
Object
  • Object
show all
Defined in:
lib/eost/eosscan.rb

Overview

classe para acesso dados blockchain EOS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(www: 'https://eos.greymass.com') ⇒ Eosscan

Returns acesso dados blockchain EOS.



15
16
17
18
# File 'lib/eost/eosscan.rb', line 15

def initialize(www: 'https://eos.greymass.com')
  @url = www
  # load_specs
end

Instance Attribute Details

#urlString (readonly)

Returns endereco da API blockchain EOS.

Returns:

  • (String)

    endereco da API blockchain EOS



10
11
12
# File 'lib/eost/eosscan.rb', line 10

def url
  @url
end

Instance Method Details

#adapter<Symbol>

Returns adapter for the connection - default :net_http.

Returns:

  • (<Symbol>)

    adapter for the connection - default :net_http



21
22
23
# File 'lib/eost/eosscan.rb', line 21

def adapter
  @adapter ||= Faraday.default_adapter
end

#chain_get_account(**args) ⇒ Hash

Returns dados numa carteira EOS.

Examples:

chain_get_account

{
  'account_name': '...',
  'head_block_num': 138_586_631,
  'head_block_time': '2020-08-26T10:16:05.500',
  'privileged': false,
  'last_code_update': '1970-01-01T00:00:00.000',
  'created': '2018-06-09T13:14:37.000',
  # DEVOLVIDO 'core_liquid_balance': '1232.0226 EOS',
  'ram_quota': 9548,
  'net_weight': 10_001_142,
  'cpu_weight': 10_001_144,
  'total_resources': {
    'owner': '...',
  # DEVOLVIDO   'net_weight': '1000.1142 EOS',
  # DEVOLVIDO   'cpu_weight': '1000.1144 EOS',
    'ram_bytes': 8148
  },
  'net_limit': { 'used': 0, 'available': 1_068_152_841, 'max': 1_068_152_841 },
  'cpu_limit': { 'used': 338, 'available': 90_856, 'max': 91_194 },
  'ram_usage': 3574,
  'permissions': [
    {
      'perm_name': 'active',
      'parent': 'owner',
      'required_auth': {
        'threshold': 1,
        'keys': [{ 'key': '...', 'weight': 1 }],
        'accounts': [],
        'waits': []
      }
    },
    {
      'perm_name': 'owner',
      'parent': '',
      'required_auth': {
        'threshold': 1,
        'keys': [{ 'key': '...', 'weight': 1 }],
        'accounts': [],
        'waits': []
      }
    }
  ],
  'self_delegated_bandwidth': {
    'from': '...', 'to': '...', 'net_weight': '1000.1142 EOS', 'cpu_weight': '1000.1144 EOS'
  },
  'refund_request': nil,
  'voter_info': {
    'owner': '...',
    'proxy': '...',
    'producers': [],
    'staked': 20_002_286,
    'last_vote_weight': '17172913021904.12109375000000000',
    'proxied_vote_weight': '0.00000000000000000',
    'is_proxy': 0,
    'flags1': 0,
    'reserved2': 0,
    'reserved3': '0.0000 EOS'
  },
  'rex_info': nil
}

Returns:

  • (Hash)

    dados numa carteira EOS



98
99
100
# File 'lib/eost/eosscan.rb', line 98

def (**args)
  JSON.parse(conn.post('/v1/chain/get_account', args.to_json, content_type: 'application/json').body)
end

#conn<Faraday::Connection>

manage the default properties and the middleware stack for fulfilling an HTTP request

Returns:

  • (<Faraday::Connection>)

    connection object with an URL & adapter



28
29
30
31
32
33
34
# File 'lib/eost/eosscan.rb', line 28

def conn
  @conn ||=
    Faraday.new(url: url) do |c|
      c.request(:url_encoded)
      c.adapter(adapter)
    end
end

#history_get_actions(**args) ⇒ Hash

Returns dados das transacoes ligadas a uma carteira EOS.

Examples:

history_get_actions

{
  'actions' => [
    {
      'account_action_seq': 937,
      'action_trace': {
        'account_ram_deltas': [],
        'act': {
          'account': 'newsblockone',
          'authorization': [
            { 'actor': 'blockonenews', 'permission': 'active' },
            { 'actor': 'newsblockone', 'permission': 'active' }
          ],
          'data': {
            'from': 'newsblockone',
            'memo': '100 million EOS tokens released on the network - EOS Reallocation Program @ get-eos.io',
            'quantity': '1.0000 NEWS',
            'to': '...'
          },
          'hex_data': 'a02685',
          'name': 'transfer'
        },
        'action_ordinal': 20,
        'block_num': 135_581_543,
        'block_time': '2020-08-09T00:45:41.000',
        'closest_unnotified_ancestor_action_ordinal': 10,
        'context_free': false,
        'creator_action_ordinal': 10,
        'elapsed': 17,
        'producer_block_id': '0814cf67c5dfe81e8647be1ddec70a8c84c45e1d65779132ace3561be044a12c',
        'receipt': {
          'abi_sequence': 2,
          'act_digest': '8b2a534341229734f1532430ffcd40c30c7b82da30c3f23446f248c2e1209a68',
          'auth_sequence': [['blockonenews', 485_788], ['newsblockone', 368_458]],
          'code_sequence': 2,
          'global_sequence': 204_352_530_651,
          'receiver': '...',
          'recv_sequence': 900
        },
        'receiver': '...',
        'trx_id': 'de327b9ba02f2fbca9eb2ee3a4e26f8ead6198248b52d184e1f480c578705ba9'
      },
      'block_num': 135_581_543,
      'block_time': '2020-08-09T00:45:41.000',
      # DELETED 'global_action_seq': 204_352_530_651,
      'irreversible': true
    }
  ],
  'head_block_num' => 138_936_528,
  'last_irreversible_block' => 138_936_194
}

Returns:

  • (Hash)

    dados das transacoes ligadas a uma carteira EOS



154
155
156
# File 'lib/eost/eosscan.rb', line 154

def history_get_actions(**args)
  JSON.parse(conn.post('/v1/history/get_actions', args.to_json, content_type: 'application/json').body)
end