class Web3::Hpb::Transaction

Constants

CONSTRUCTOR_SEQ

Attributes

raw_data[R]

Public Class Methods

new(transaction_data) click to toggle source
# File lib/web3/hpb/transaction.rb, line 10
def initialize transaction_data
  @raw_data = transaction_data
  transaction_data.each do |k, v|
    self.instance_variable_set("@#{k}", v)
    self.class.send(:define_method, k, proc {self.instance_variable_get("@#{k}")})
  end
end

Public Instance Methods

block_number() click to toggle source
# File lib/web3/hpb/transaction.rb, line 38
def block_number
  # if transaction is less than 12 seconds old, blockNumber will be nil
  # :. nil check before calling `to_hex` to avoid argument error
  blockNumber && from_hex(blockNumber)
end
call_input_data() click to toggle source

suffix # 0xa1 0x65 'b' 'z' 'z' 'r' '0' 0x58 0x20 <32 bytes swarm hash> 0x00 0x29 look solidity.readthedocs.io/en/latest/metadata.html for details

# File lib/web3/hpb/transaction.rb, line 28
def call_input_data
  if raw_data['creates'] && input
    fetch_constructor_data input
  elsif input && input.length>10
    input[10..input.length]
  else
    []
  end
end
gasPrice_hpb() click to toggle source
# File lib/web3/hpb/transaction.rb, line 56
def gasPrice_hpb
  wei_to_hpb(from_hex gasPrice)
end
gas_limit() click to toggle source
# File lib/web3/hpb/transaction.rb, line 52
def gas_limit
  from_hex gas
end
method_hash() click to toggle source
# File lib/web3/hpb/transaction.rb, line 18
def method_hash
  if input && input.length>=10
    input[2...10]
  else
    nil
  end
end
value_hpb() click to toggle source
# File lib/web3/hpb/transaction.rb, line 48
def value_hpb
  wei_to_hpb(from_hex value)
end
value_wei() click to toggle source
# File lib/web3/hpb/transaction.rb, line 44
def value_wei
  from_hex(value)
end

Private Instance Methods

fetch_constructor_data(input) click to toggle source
# File lib/web3/hpb/transaction.rb, line 63
def fetch_constructor_data input
  data = input[CONSTRUCTOR_SEQ,1]
  while data && (d = data[CONSTRUCTOR_SEQ,1])
    data = d
  end
  data
end