Class: Ethereum::Address

Inherits:
Object show all
Defined in:
lib/ethereum/address.rb

Constant Summary collapse

BLANK =
''.freeze
ZERO =
("\x00"*20).freeze
CREATE_CONTRACT =
BLANK

Instance Method Summary collapse

Constructor Details

#initialize(s) ⇒ Address

Returns a new instance of Address.



11
12
13
# File 'lib/ethereum/address.rb', line 11

def initialize(s)
  @bytes = parse s
end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ethereum/address.rb', line 27

def blank?
  @bytes == BLANK
end

#checksum(bytes = nil) ⇒ Object



23
24
25
# File 'lib/ethereum/address.rb', line 23

def checksum(bytes=nil)
  Utils.keccak256(bytes||@bytes)[0,4]
end

#to_bytes(extended = false) ⇒ Object



15
16
17
# File 'lib/ethereum/address.rb', line 15

def to_bytes(extended=false)
  extended ? "#{@bytes}#{checksum}" : @bytes
end

#to_hex(extended = false) ⇒ Object



19
20
21
# File 'lib/ethereum/address.rb', line 19

def to_hex(extended=false)
  Utils.encode_hex to_bytes(extended)
end