Ether Binder
Set of utilities for interacting with Ethereum and it's smart contracts with PHP, with generating ABI bindings and Ethereum-related types
|
Static Public Member Functions | |
static | mustHexLen (string $hex, int $len) |
static | lPadHex (string $hex, int $padTo, bool $closestMultiplier=true) |
static | int2hex (int $val, bool $with0x=true) |
static | hex2int (string $val) |
static | getPessimisticBlockBaseFee (Block $previous, int $blocksAhead, ?EIP1559Config $config=null) |
static | hex2bin (string $hex) |
static | getNextBlockBaseFee (Block $previous, EIP1559Config $config) |
static | waitForTxReceipt (Transaction|Hash $txHash, AbstractRPC $rpc, int $timeoutSeconds=60, int $intervalMS=500) |
Functions is an abstract utility class that holds static utility methods.
|
static |
Calculates the base fee for the next block in an EIP1559 compatible chain.
Block | $previous | The previous block. |
EIP1559Config | $config | The EIP1559 configuration. Only required field is $config->activationBlockNumber |
|
static |
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
Block | $previous | |
int | $blocksAhead | |
EIP1559Config | null | $config |
|
static |
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.
string | $hex |
InvalidHexException |
|
static |
Converts hex string to integer
string | $val | The hexadecimal string |
EthBinderRuntimeException | when number exceeds PHP_INT_MAX |
|
static |
Converts an integer to a hex string.
int | $val | The integer value. |
bool | $with0x | Whether to include the "0x" prefix. |
|
static |
Left-pads a hex string to a specific length.
string | $hex | The hex string. |
int | $padTo | The length to pad to. |
bool | $closestMultiplier | Whether to pad to the closest multiple of $padTo, instead of just to $padTo |
|
static |
Validates the length of a hexadecimal string. In case the length is invalid, exception is risen.
string | $hex | The hex string. |
int | $len | The expected length. |
InvalidHexException | |
InvalidHexLengthException |
|
static |
This function will wait and block until the transaction is confirmed via repetatively checking receipt
Transaction | Hash | $txHash | Hash of the transaction or signed transaction |
AbstractRPC | $rpc | RPC to use for transaction receipt pooling |
int | $timeoutSeconds | After how many seconds to give up |
int | $intervalMS | How long to wait between pooling attempts |
EthBinderRuntimeException | if timeout happens. It does not mean the transaction will not get confirmed! |
EthBinderLogicException | |
NotSupportedException |