Class: CryptocoinPayable::Adapters::Ethereum
- Inherits:
-
Base
- Object
- Base
- CryptocoinPayable::Adapters::Ethereum
show all
- Defined in:
- lib/cryptocoin_payable/adapters/ethereum.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#convert_main_to_subunit, #convert_subunit_to_main, #fetch_rate
Class Method Details
.coin_symbol ⇒ Object
11
12
13
|
# File 'lib/cryptocoin_payable/adapters/ethereum.rb', line 11
def self.coin_symbol
'ETH'
end
|
.subunit_in_main ⇒ Object
7
8
9
|
# File 'lib/cryptocoin_payable/adapters/ethereum.rb', line 7
def self.subunit_in_main
1_000_000_000_000_000_000
end
|
Instance Method Details
#create_address(id) ⇒ Object
28
29
30
|
# File 'lib/cryptocoin_payable/adapters/ethereum.rb', line 28
def create_address(id)
Eth::Utils.public_key_to_address(super.public_key.uncompressed.to_hex)
end
|
#fetch_transactions(address) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/cryptocoin_payable/adapters/ethereum.rb', line 15
def fetch_transactions(address)
api_adapter_key = coin_config.try(:adapter_api_key)
url = "https://#{subdomain}.etherscan.io/api?module=account&action=txlist&address=#{address}&tag=latest"
url += '?apiKey=' + api_adapter_key if api_adapter_key
response = get_request(url)
json = JSON.parse(response.body)
raise ApiError, json['message'] if json['status'] == '0' && json['message'] == 'NOTOK'
json['result'].map { |tx| convert_transactions(tx, address) }
end
|