Documentation

Hash
in package
implements BinarySerializableInterface, HashSerializable

Hash is a class for representing Ethereum hashes and sets structure and method for another single value data types such as Ethereum Address.

Tags
author

DubbaThony

Table of Contents

Interfaces

BinarySerializableInterface
HashSerializable
Hash serializable is interface to mark classes that can serialize themselves into blob of max size of hash (ie. fit abi single slot that's 32 bytes)

Constants

dataSizeBytes  = 32

Properties

$bytes  : string

Methods

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.
isNull()  : bool
Checks if inner data contains only zeroes (equals to `static::NULL()`)
NULL()  : static
Initializes object with all zeros.
toBin()  : string
Converts the internal data into to a binary string.
toHex()  : string
Converts the internal data into to a hexadecimal string.
__construct()  : mixed

Constants

dataSizeBytes

protected mixed dataSizeBytes = 32

Properties

$bytes

protected string $bytes

Methods

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
throws
InvalidLengthException
Return values
static

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.

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

        
On this page

Search results