Class: EthereumContractABI::Util
- Inherits:
-
Object
- Object
- EthereumContractABI::Util
- Defined in:
- lib/ethereum-contract-abi/util.rb
Class Method Summary collapse
- .fromHexByteString(str, with_prefix: true) ⇒ Object
- .keccak_hash(str) ⇒ Object
- .remove_hex_prefix(str) ⇒ Object
- .toHexByteString(str) ⇒ Object
Class Method Details
.fromHexByteString(str, with_prefix: true) ⇒ Object
11 12 13 14 |
# File 'lib/ethereum-contract-abi/util.rb', line 11 def self.fromHexByteString(str, with_prefix: true) prefix = with_prefix ? "0x" : "" prefix + str.unpack("H*").first end |
.keccak_hash(str) ⇒ Object
20 21 22 |
# File 'lib/ethereum-contract-abi/util.rb', line 20 def self. keccak_hash(str) [Digest::Keccak256.new.hexdigest(signature)].pack("H*") end |
.remove_hex_prefix(str) ⇒ Object
16 17 18 |
# File 'lib/ethereum-contract-abi/util.rb', line 16 def self.remove_hex_prefix(str) str.slice(2, str.length) end |
.toHexByteString(str) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/ethereum-contract-abi/util.rb', line 4 def self.toHexByteString(str) if str.start_with?("0x") return [str.slice(2, str.length)].pack("H*") end [str].pack("H*") end |