Class: Ethereum::Address
Constant Summary collapse
- BLANK =
''.freeze
- ZERO =
("\x00"*20).freeze
- CREATE_CONTRACT =
BLANK
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #checksum(bytes = nil) ⇒ Object
-
#initialize(s) ⇒ Address
constructor
A new instance of Address.
- #to_bytes(extended = false) ⇒ Object
- #to_hex(extended = false) ⇒ Object
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
#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 |