Address
extends Hash
in package
Address is a class for representing and manipulating Ethereum addresses.
Tags
Table of Contents
Constants
- dataSizeBytes = 20
Properties
- $bytes : string
Methods
- __toString() : string
- checksummed() : string
- Returns checksummed hex representation of the address.
- eq() : bool
- Checks for equality with another Hash or Hash-derivative object.
- fromBin() : static
- Initializes from a binary string.
- fromHex() : static
- Initializes from a hexadecimal string. Validates checksum and throws a BadAddressChecksumException when it does not match. If entire address is upper or lower case, the checksum is ommited.
- isNull() : bool
- Checks if inner data contains only zeroes (equals to `static::NULL()`)
- NULL() : static
- Initializes object with all zeros.
- testChecksum() : bool
- Validates the checksum of a hexadecimal address. If all characters are upper or lower case, it skips the check and returns true.
- toBin() : string
- Converts the internal data into to a binary string.
- toHex() : string
- Converts the internal data into to a hexadecimal string.
- __construct() : mixed
- checksum() : string
Constants
dataSizeBytes
protected
mixed
dataSizeBytes
= 20
Properties
$bytes
protected
string
$bytes
Methods
__toString()
public
__toString() : string
Tags
Return values
stringchecksummed()
Returns checksummed hex representation of the address.
public
checksummed() : string
Tags
Return values
string —Checksummed address.
eq()
Checks for equality with another Hash or Hash-derivative object.
public
eq(static $b) : bool
Parameters
- $b : static
-
Another object to compare against.
Return values
bool —True if equal, false otherwise.
fromBin()
Initializes from a binary string.
public
static fromBin(string $bin) : static
Parameters
- $bin : string
-
Binary data.
Tags
Return values
staticfromHex()
Initializes from a hexadecimal string. Validates checksum and throws a BadAddressChecksumException when it does not match. If entire address is upper or lower case, the checksum is ommited.
public
static fromHex(string $hex) : static
Parameters
- $hex : string
-
Hexadecimal representation of the address.
Tags
Return values
static —The Address object.
isNull()
Checks if inner data contains only zeroes (equals to `static::NULL()`)
public
isNull() : bool
Return values
bool —true if inner data is null data, false otherwise
NULL()
Initializes object with all zeros.
public
static NULL() : static
Return values
static —The null object.
testChecksum()
Validates the checksum of a hexadecimal address. If all characters are upper or lower case, it skips the check and returns true.
public
static testChecksum(string $hexAddr) : bool
Parameters
- $hexAddr : string
-
Hexadecimal address to test.
Tags
Return values
bool —True if valid, false otherwise.
toBin()
Converts the internal data into to a binary string.
public
toBin() : string
Return values
string —Binary representation.
toHex()
Converts the internal data into to a hexadecimal string.
public
toHex([bool $with0x = true ]) : string
Parameters
- $with0x : bool = true
-
Flag to include "0x" prefix or not.
Return values
string —Hexadecimal representation.
__construct()
private
__construct(string $bytes) : mixed
Parameters
- $bytes : string
checksum()
private
static checksum(string $hexAddr) : string
Parameters
- $hexAddr : string