Class: Paleth::TransactionReceipt

Inherits:
Object
  • Object
show all
Defined in:
lib/paleth/transaction_receipt.rb

Overview

Repesents a transaction on an ethereum blockchain

Constant Summary collapse

SIMPLE_METHODS =
%i(block_hash block_number transaction_hash
transaction_index from to cumulative_gas_user
gas_used contract_address logs status)

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ TransactionReceipt

Returns a new instance of TransactionReceipt.


4
5
6
# File 'lib/paleth/transaction_receipt.rb', line 4

def initialize(data)
  @data = data
end

Instance Method Details

#failure?Boolean

Returns:

  • (Boolean)

21
22
23
# File 'lib/paleth/transaction_receipt.rb', line 21

def failure?
  status.zero?
end

#success?Boolean

Returns:

  • (Boolean)

17
18
19
# File 'lib/paleth/transaction_receipt.rb', line 17

def success?
  status == 1
end

#to_sObject


25
26
27
28
29
30
31
32
# File 'lib/paleth/transaction_receipt.rb', line 25

def to_s
  data = SIMPLE_METHODS.flatten.map do |name|
    value = self.send(name)
    "#{name}=#{value}"
  end.join(', ')

  "TransactionReceipt(#{data})"
end