Class: Ethereum::Transaction
- Inherits:
-
Object
- Object
- Ethereum::Transaction
- Defined in:
- lib/ethereum/transaction.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#id ⇒ Object
Returns the value of attribute id.
-
#input ⇒ Object
Returns the value of attribute input.
-
#input_parameters ⇒ Object
Returns the value of attribute input_parameters.
-
#mined ⇒ Object
Returns the value of attribute mined.
Class Method Summary collapse
Instance Method Summary collapse
- #address ⇒ Object
-
#initialize(id, connection, data, input_parameters = []) ⇒ Transaction
constructor
A new instance of Transaction.
- #mined? ⇒ Boolean
- #wait_for_miner(timeout = 1500.seconds) ⇒ Object
Constructor Details
#initialize(id, connection, data, input_parameters = []) ⇒ Transaction
Returns a new instance of Transaction.
6 7 8 9 10 11 12 |
# File 'lib/ethereum/transaction.rb', line 6 def initialize(id, connection, data, input_parameters = []) @mined = false @connection = connection @id = id @input = data @input_parameters = input_parameters end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
4 5 6 |
# File 'lib/ethereum/transaction.rb', line 4 def connection @connection end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/ethereum/transaction.rb', line 4 def id @id end |
#input ⇒ Object
Returns the value of attribute input.
4 5 6 |
# File 'lib/ethereum/transaction.rb', line 4 def input @input end |
#input_parameters ⇒ Object
Returns the value of attribute input_parameters.
4 5 6 |
# File 'lib/ethereum/transaction.rb', line 4 def input_parameters @input_parameters end |
#mined ⇒ Object
Returns the value of attribute mined.
4 5 6 |
# File 'lib/ethereum/transaction.rb', line 4 def mined @mined end |
Class Method Details
.from_blockchain(address, connection = IpcClient.new) ⇒ Object
32 33 34 |
# File 'lib/ethereum/transaction.rb', line 32 def self.from_blockchain(address, connection = IpcClient.new) Transaction.new(address, connection, nil, nil) end |
Instance Method Details
#address ⇒ Object
14 15 16 |
# File 'lib/ethereum/transaction.rb', line 14 def address @id end |
#mined? ⇒ Boolean
18 19 20 21 |
# File 'lib/ethereum/transaction.rb', line 18 def mined? return true if @mined @mined = @connection.eth_get_transaction_by_hash(@id)["result"]["blockNumber"].present? end |
#wait_for_miner(timeout = 1500.seconds) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/ethereum/transaction.rb', line 23 def wait_for_miner(timeout = 1500.seconds) start_time = Time.now while self.mined? == false raise Timeout::Error if ((Time.now - start_time) > timeout) sleep 5 return true if self.mined? end end |