Class: Kortana::Modules::Blockchain

Inherits:
Object
  • Object
show all
Defined in:
lib/kortana/modules/blockchain.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Blockchain

Returns a new instance of Blockchain.



4
5
6
# File 'lib/kortana/modules/blockchain.rb', line 4

def initialize(client)
  @client = client
end

Instance Method Details

#estimate_gas(params) ⇒ Object



25
26
27
28
# File 'lib/kortana/modules/blockchain.rb', line 25

def estimate_gas(params)
  res = @client.post("/blockchain/estimate-gas", params)
  res["gasLimit"].to_i
end

#get_block(block_number_or_hash) ⇒ Object



8
9
10
# File 'lib/kortana/modules/blockchain.rb', line 8

def get_block(block_number_or_hash)
  @client.get("/blockchain/blocks/#{block_number_or_hash}")
end

#get_gas_priceObject



20
21
22
23
# File 'lib/kortana/modules/blockchain.rb', line 20

def get_gas_price
  res = @client.get("/blockchain/gas-price")
  res["gasPrice"].to_i
end

#get_logs(filter) ⇒ Object



34
35
36
# File 'lib/kortana/modules/blockchain.rb', line 34

def get_logs(filter)
  @client.post("/blockchain/logs", filter)
end

#get_network_statusObject



30
31
32
# File 'lib/kortana/modules/blockchain.rb', line 30

def get_network_status
  @client.get("/blockchain/status")
end

#get_token_balance(address, token_address) ⇒ Object



42
43
44
45
# File 'lib/kortana/modules/blockchain.rb', line 42

def get_token_balance(address, token_address)
  res = @client.get("/blockchain/addresses/#{address}/token-balance", { token: token_address })
  res["balance"].to_i
end

#get_transaction(tx_hash) ⇒ Object



12
13
14
# File 'lib/kortana/modules/blockchain.rb', line 12

def get_transaction(tx_hash)
  @client.get("/blockchain/transactions/#{tx_hash}")
end

#get_transaction_receipt(tx_hash) ⇒ Object



16
17
18
# File 'lib/kortana/modules/blockchain.rb', line 16

def get_transaction_receipt(tx_hash)
  @client.get("/blockchain/transactions/#{tx_hash}/receipt")
end

#get_validatorsObject



38
39
40
# File 'lib/kortana/modules/blockchain.rb', line 38

def get_validators
  @client.get("/blockchain/validators")
end