Class: BlockGiven::Receipt
- Inherits:
-
Object
- Object
- BlockGiven::Receipt
- Defined in:
- lib/block_given/receipt.rb
Overview
Transaction receipt with symbolized, integer-decoded fields.
Instance Attribute Summary collapse
-
#to_h ⇒ Object
readonly
Returns the value of attribute to_h.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #block_hash ⇒ Object
- #block_number ⇒ Object
- #contract_address ⇒ Object
- #cumulative_gas_used ⇒ Object
- #effective_gas_price ⇒ Object
-
#fee ⇒ Object
Total fee paid in wei.
- #from ⇒ Object
- #gas_used ⇒ Object
-
#initialize(raw) ⇒ Receipt
constructor
A new instance of Receipt.
- #inspect ⇒ Object
- #logs ⇒ Object
- #reverted? ⇒ Boolean
-
#status ⇒ Object
:success / :reverted (pre-Byzantium receipts have no status: treated as success).
- #success? ⇒ Boolean
- #to ⇒ Object
- #transaction_hash ⇒ Object
- #transaction_index ⇒ Object
Constructor Details
#initialize(raw) ⇒ Receipt
Returns a new instance of Receipt.
8 9 10 |
# File 'lib/block_given/receipt.rb', line 8 def initialize(raw) @to_h = raw.is_a?(Receipt) ? raw.to_h : Normalizer.normalize(raw) end |
Instance Attribute Details
#to_h ⇒ Object (readonly)
Returns the value of attribute to_h.
6 7 8 |
# File 'lib/block_given/receipt.rb', line 6 def to_h @to_h end |
Instance Method Details
#[](key) ⇒ Object
37 |
# File 'lib/block_given/receipt.rb', line 37 def [](key) = to_h[key.to_sym] |
#block_hash ⇒ Object
14 |
# File 'lib/block_given/receipt.rb', line 14 def block_hash = to_h[:block_hash] |
#block_number ⇒ Object
13 |
# File 'lib/block_given/receipt.rb', line 13 def block_number = to_h[:block_number] |
#contract_address ⇒ Object
17 |
# File 'lib/block_given/receipt.rb', line 17 def contract_address = to_h[:contract_address] |
#cumulative_gas_used ⇒ Object
20 |
# File 'lib/block_given/receipt.rb', line 20 def cumulative_gas_used = to_h[:cumulative_gas_used] |
#effective_gas_price ⇒ Object
19 |
# File 'lib/block_given/receipt.rb', line 19 def effective_gas_price = to_h[:effective_gas_price] |
#fee ⇒ Object
Total fee paid in wei.
35 |
# File 'lib/block_given/receipt.rb', line 35 def fee = gas_used && effective_gas_price ? gas_used * effective_gas_price : nil |
#from ⇒ Object
15 |
# File 'lib/block_given/receipt.rb', line 15 def from = to_h[:from] |
#gas_used ⇒ Object
18 |
# File 'lib/block_given/receipt.rb', line 18 def gas_used = to_h[:gas_used] |
#inspect ⇒ Object
39 40 41 42 |
# File 'lib/block_given/receipt.rb', line 39 def inspect "#<BlockGiven::Receipt #{transaction_hash} status=#{status} block=#{block_number} " \ "gas_used=#{gas_used} logs=#{logs.size}>" end |
#logs ⇒ Object
22 |
# File 'lib/block_given/receipt.rb', line 22 def logs = to_h[:logs] || [] |
#reverted? ⇒ Boolean
32 |
# File 'lib/block_given/receipt.rb', line 32 def reverted? = status == :reverted |
#status ⇒ Object
:success / :reverted (pre-Byzantium receipts have no status: treated as success).
25 26 27 28 29 |
# File 'lib/block_given/receipt.rb', line 25 def status return :success if to_h[:status].nil? to_h[:status] == 1 ? :success : :reverted end |
#success? ⇒ Boolean
31 |
# File 'lib/block_given/receipt.rb', line 31 def success? = status == :success |
#to ⇒ Object
16 |
# File 'lib/block_given/receipt.rb', line 16 def to = to_h[:to] |
#transaction_hash ⇒ Object
12 |
# File 'lib/block_given/receipt.rb', line 12 def transaction_hash = to_h[:transaction_hash] |
#transaction_index ⇒ Object
21 |
# File 'lib/block_given/receipt.rb', line 21 def transaction_index = to_h[:transaction_index] |