Class: Etheruby::Encoders::Address

Inherits:
Base
  • Object
show all
Defined in:
lib/etheruby/encoders/address.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



15
16
17
18
# File 'lib/etheruby/encoders/address.rb', line 15

def decode
  v, s = Uint.new(data).decode
  return "0x#{v.to_s(16).rjust(40, "0")}", s
end

#encodeObject



7
8
9
10
11
12
13
# File 'lib/etheruby/encoders/address.rb', line 7

def encode
  if data.is_a?(::String)
    Uint.new(data[2..64].to_i(16)).encode
  else
    Uint.new(data).encode
  end
end