Class: Etherlite::Transaction
- Inherits:
-
Object
- Object
- Etherlite::Transaction
- Defined in:
- lib/etherlite/transaction.rb
Instance Attribute Summary collapse
-
#receipt ⇒ Object
readonly
Returns the value of attribute receipt.
-
#tx_hash ⇒ Object
readonly
Returns the value of attribute tx_hash.
Instance Method Summary collapse
- #block_number ⇒ Object
- #contract_address ⇒ Object
- #gas_used ⇒ Object
-
#initialize(_connection, _tx_hash) ⇒ Transaction
constructor
A new instance of Transaction.
- #mined? ⇒ Boolean
- #refresh ⇒ Object
- #wait_for_block(timeout: 120) ⇒ Object
Constructor Details
#initialize(_connection, _tx_hash) ⇒ Transaction
Returns a new instance of Transaction.
5 6 7 8 9 |
# File 'lib/etherlite/transaction.rb', line 5 def initialize(_connection, _tx_hash) @connection = _connection @tx_hash = _tx_hash @receipt = {} end |
Instance Attribute Details
#receipt ⇒ Object (readonly)
Returns the value of attribute receipt.
3 4 5 |
# File 'lib/etherlite/transaction.rb', line 3 def receipt @receipt end |
#tx_hash ⇒ Object (readonly)
Returns the value of attribute tx_hash.
3 4 5 |
# File 'lib/etherlite/transaction.rb', line 3 def tx_hash @tx_hash end |
Instance Method Details
#block_number ⇒ Object
24 25 26 |
# File 'lib/etherlite/transaction.rb', line 24 def block_number Utils.hex_to_uint @receipt['blockNumber'] end |
#contract_address ⇒ Object
28 29 30 |
# File 'lib/etherlite/transaction.rb', line 28 def contract_address @receipt['contractAddress'] end |
#gas_used ⇒ Object
20 21 22 |
# File 'lib/etherlite/transaction.rb', line 20 def gas_used Utils.hex_to_uint @receipt['gasUsed'] end |
#mined? ⇒ Boolean
16 17 18 |
# File 'lib/etherlite/transaction.rb', line 16 def mined? @receipt.key? 'blockNumber' end |
#refresh ⇒ Object
11 12 13 14 |
# File 'lib/etherlite/transaction.rb', line 11 def refresh @receipt = @connection.eth_get_transaction_receipt(@tx_hash) || {} mined? end |
#wait_for_block(timeout: 120) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/etherlite/transaction.rb', line 32 def wait_for_block(timeout: 120) start = Time.now while !refresh return false if Time.now - start > timeout sleep 1 end true end |