Class: Etheruby::Encoders::Function

Inherits:
Base
  • Object
show all
Defined in:
lib/etheruby/encoders/function.rb

Instance Attribute Summary

Attributes inherited from Base

#data

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Etheruby::Encoders::Base

Instance Method Details

#decodeObject



12
13
14
15
16
17
18
# File 'lib/etheruby/encoders/function.rb', line 12

def decode
  address, selector = data[0..39], data[40..47]
  return {
    address: Address.new(address).decode[0],
    selector: "0x#{selector}"
  }, 32
end

#encodeObject



8
9
10
# File 'lib/etheruby/encoders/function.rb', line 8

def encode
  (data[:address].to_s(16) + data[:selector].to_s(16)).ljust(64, '0')
end

#to_sObject



20
21
22
# File 'lib/etheruby/encoders/function.rb', line 20

def to_s
  encode
end