module Web3::Eth::Utility

Public Instance Methods

from_hex(h) click to toggle source
# File lib/web3/eth/utility.rb, line 14
def from_hex h
  h.nil? ? 0 : (h.kind_of?(String) ? h.to_i(16) : h)
end
hex(num) click to toggle source
# File lib/web3/eth/utility.rb, line 6
def hex num
  '0x' + num.to_s(16)
end
remove_0x_head(s) click to toggle source
# File lib/web3/eth/utility.rb, line 18
def remove_0x_head(s)
  return s if !s || s.length<2
  s[0,2] == '0x' ? s[2..-1] : s
end
wei_to_ether(wei) click to toggle source
# File lib/web3/eth/utility.rb, line 10
def wei_to_ether(wei)
  1.0 * wei / 10**18
end