Documentation

Functions
in package

AbstractYes

Functions is an abstract utility class that holds static utility methods.

Tags
author

DubbaThony

Table of Contents

Methods

getNextBlockBaseFee()  : OOGmp
Calculates the base fee for the next block in an EIP1559 compatible chain.
getPessimisticBlockBaseFee()  : OOGmp
Returns worst case scenario base fee for block currentBlock + blocksAhead. Useful for estimating base fee for transactions. Since the fee is base fee, it shouldn't matter if it's overestimated, since consensus will prevent spending surplus
hex2bin()  : string
0x tolerant, exceptions-compatible hex2bin() drop-in replacement, that never returns false, handles empty strings and prefixes "0" if odd amount of characters is spotted.
hex2int()  : int
Converts hex string to integer
int2hex()  : string
Converts an integer to a hex string.
lPadHex()  : string
Left-pads a hex string to a specific length.
mustHexLen()  : void
Validates the length of a hexadecimal string. In case the length is invalid, exception is risen.
waitForTxReceipt()  : Receipt
This function will wait and block until the transaction is confirmed via repetatively checking receipt

Methods

getNextBlockBaseFee()

Calculates the base fee for the next block in an EIP1559 compatible chain.

public static getNextBlockBaseFee(Block $previous, EIP1559Config $config) : OOGmp
Parameters
$previous : Block

The previous block.

$config : EIP1559Config

The EIP1559 configuration. Only required field is $config->activationBlockNumber

Return values
OOGmp

The calculated base fee.

getPessimisticBlockBaseFee()

Returns worst case scenario base fee for block currentBlock + blocksAhead. Useful for estimating base fee for transactions. Since the fee is base fee, it shouldn't matter if it's overestimated, since consensus will prevent spending surplus

public static getPessimisticBlockBaseFee(Block $previous, int $blocksAhead[, EIP1559Config|null $config = null ]) : OOGmp
Parameters
$previous : Block
$blocksAhead : int
$config : EIP1559Config|null = null
Return values
OOGmp

hex2bin()

0x tolerant, exceptions-compatible hex2bin() drop-in replacement, that never returns false, handles empty strings and prefixes "0" if odd amount of characters is spotted.

public static hex2bin(string $hex) : string
Parameters
$hex : string
Tags
throws
InvalidHexException
Return values
string

Binary blob

hex2int()

Converts hex string to integer

public static hex2int(string $val) : int
Parameters
$val : string

The hexadecimal string

Tags
throws
EthBinderRuntimeException

when number exceeds PHP_INT_MAX

Return values
int

The integer value

int2hex()

Converts an integer to a hex string.

public static int2hex(int $val[, bool $with0x = true ]) : string
Parameters
$val : int

The integer value.

$with0x : bool = true

Whether to include the "0x" prefix.

Return values
string

The hex string.

lPadHex()

Left-pads a hex string to a specific length.

public static lPadHex(string $hex, int $padTo[, bool $closestMultiplier = true ]) : string
Parameters
$hex : string

The hex string.

$padTo : int

The length to pad to.

$closestMultiplier : bool = true

Whether to pad to the closest multiple of $padTo, instead of just to $padTo

Return values
string

The padded hex string.

mustHexLen()

Validates the length of a hexadecimal string. In case the length is invalid, exception is risen.

public static mustHexLen(string $hex, int $len) : void
Parameters
$hex : string

The hex string.

$len : int

The expected length.

Tags
throws
InvalidHexException
throws
InvalidHexLengthException

waitForTxReceipt()

This function will wait and block until the transaction is confirmed via repetatively checking receipt

public static waitForTxReceipt(Transaction|Hash $txHash, AbstractRPC $rpc[, int $timeoutSeconds = 60 ][, int $intervalMS = 500 ]) : Receipt
Parameters
$txHash : Transaction|Hash

Hash of the transaction or signed transaction

$rpc : AbstractRPC

RPC to use for transaction receipt pooling

$timeoutSeconds : int = 60

After how many seconds to give up

$intervalMS : int = 500

How long to wait between pooling attempts

Tags
throws
EthBinderRuntimeException

if timeout happens. It does not mean the transaction will not get confirmed!

throws
EthBinderLogicException
throws
NotSupportedException
Return values
Receipt

Transaction receipt


        
On this page

Search results