Class: Ethmo::Transaction

Inherits:
Hash
  • Object
show all
Defined in:
lib/ethmo/transaction.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Transaction

Returns a new instance of Transaction.



6
7
8
9
10
# File 'lib/ethmo/transaction.rb', line 6

def initialize(hash)
  # TODO: Add read transaction from hash support
  # NOTE: Current only support direct merge transaction
  merge! hash
end

Instance Method Details

#contract?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/ethmo/transaction.rb', line 16

def contract?
  to.nil?
end

#fromObject



20
21
22
# File 'lib/ethmo/transaction.rb', line 20

def from
  self['from']
end

#toObject



24
25
26
# File 'lib/ethmo/transaction.rb', line 24

def to
  self['to']
end

#transfer?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/ethmo/transaction.rb', line 12

def transfer?
  value.positive?
end

#valueObject



28
29
30
31
32
33
# File 'lib/ethmo/transaction.rb', line 28

def value
  @value ||=
    fetch('value', '0x0')
    .to_i(16)
    .to_f / Config::WEI
end