Class: Etherscan::Accounts

Inherits:
Api
  • Object
show all
Defined in:
lib/etherscan/accounts.rb

Instance Attribute Summary

Attributes inherited from Api

#connection

Instance Method Summary collapse

Methods inherited from Api

#get, #initialize

Constructor Details

This class inherits a constructor from Etherscan::Api

Instance Method Details

#address_balance(address) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/etherscan/accounts.rb', line 5

def address_balance(address)
  params = {
    module: 'account', action: 'balance',
    address: address, tag: 'latest'
  }
  get(params)
end

#internal_transactions(address, args = {}) ⇒ Object

Get a list of ‘Internal’ Transactions By Address Available args: start_block, end_block, sort, page, offset



37
38
39
40
# File 'lib/etherscan/accounts.rb', line 37

def internal_transactions(address, args = {})
  action = 'txlistinternal'
  transcations(action, address, nil, args)
end

#multi_address_balance(addresses) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/etherscan/accounts.rb', line 13

def multi_address_balance(addresses)
  fail Etherscan::Exception, 'up to 20 accounts in a single batch' if addresses.size > 20
  params = {
    module: 'account', action: 'balancemulti',
    address: addresses.join(','), tag: 'latest'
  }
  get(params)
end

#normal_transactions(address, args = {}) ⇒ Object

Get a list of ‘Normal’ Transactions By Address if page is not defined Returns up to 10000 last transactions Available args: start_block, end_block, sort, page, offset

Parameters:

  • sort- ('asc'>'des'>)

    ort ‘asc’ -> ascending order, ‘des’ -> descending order

  • start_block

    starting blockNo to retrieve results

  • end_block

    ending blockNo to retrieve results

  • page

    Paginated result <page number>

  • offset

    max records to return



30
31
32
33
# File 'lib/etherscan/accounts.rb', line 30

def normal_transactions(address, args = {})
  action = 'txlist'
  transcations(action, address, nil, args)
end

#token_transactions(contract_address, address = nil, args = {}) ⇒ Object

Get a list of “ERC20 - Token Transfer Events” Available args: start_block, end_block, sort, page, offset

Parameters:

  • contract_address

    Token address (set nil to get a list of all ERC20 transactions)

  • address (defaults to: nil)

    Address for ERC20 transactions (optional)



46
47
48
49
50
# File 'lib/etherscan/accounts.rb', line 46

def token_transactions(contract_address, address = nil, args = {})
  fail Etherscan::Exception, 'contract or address must be defined' if (contract_address || address).nil?
  action = 'tokentx'
  transcations(action, address, contract_address, args)
end