Ether Binder
Set of utilities for interacting with Ethereum and it's smart contracts with PHP, with generating ABI bindings and Ethereum-related types
|
Public Member Functions | |
encodeBinForSigning (?int $chainId) | |
encodeBin () | |
transactionType () | |
ecRecover () | |
isReplayProtected () | |
setGasPrice (OOGmp $gasPrice) | |
useRpcEstimatesWithBump (AbstractRPC $rpc, ?Address $from, int $bumpGasPercentage, int $bumpFeePercentage) | |
toBin () | |
toHex () | |
encodeHexForSigning (?int $chainId) | |
encodeHex () | |
setNonce (int $nonce) | |
nonce () | |
setGasLimit (int $gasLimit) | |
gasLimit () | |
totalGasPrice () | |
setValueFmt (float|int|string|OOGmp $human, int|string|EtherFormats $format=EtherFormats::ETHER) | |
setValue (OOGmp $valueWEI) | |
value () | |
valueFmt (int $finalDecimals, int|string|EtherFormats $format=EtherFormats::ETHER) | |
setTo (?Address $address) | |
to () | |
setDataBin (string $dataBin) | |
setDataHex (string $dataHex) | |
dataHex () | |
dataBin () | |
v () | |
r () | |
s () | |
isSigned () | |
hash () | |
getSigningHash (?int $chainId) | |
sign (Key $key, ?int $chainId) | |
calculateV (OOGmp $recovery) | |
useRpcEstimates (AbstractRPC $rpc, Address $from) | |
deployAddress () | |
signature () | |
setSignature (Signature $s) | |
nonceFromRPC (Address $from, AbstractRPC $rpc) | |
Static Public Member Functions | |
static | decodeHex (string $rlp) |
static | decodeBin (string $rlp) |
static | fromHex (string $hex) |
static | fromBin (string $bin) |
static | fromRPCArr (array $rpcArr) |
Protected Member Functions | |
blanksFromRPCArr (array $rpcArr) | |
setInnerFromRLPValues (array $rlpValues) | |
setGasPriceOrBaseFee (OOGmp $fee) | |
Protected Attributes | |
bool | $signed = false |
int | $nonce = 0 |
int | $gas = 0 |
OOGmp | $gasPrice |
OOGmp | $value |
Address | $to = null |
string | $dataBin = "" |
OOGmp | $v |
OOGmp | $r |
OOGmp | $s |
int | $chainId = null |
LegacyTransaction is a class for handling Ethereum legacy transactions (pre EIP1559), with pre EIP155 or post EIP155 support
|
protected |
Reimplemented from M8B\EtherBinder\Common\Transaction.
|
inherited |
Calculates the recovery id (v) for signature accounting for EIP155 (replay protection).
OOGmp | $recovery | Recovery id before chain id calculations. |
Reimplemented in M8B\EtherBinder\Common\AccessListTransaction, and M8B\EtherBinder\Common\LondonTransaction.
|
inherited |
Gets the binary data payload of the transaction.
|
inherited |
Gets the transaction data in hex format.
|
staticinherited |
Decodes a binary RLP-encoded transaction. Accepts both legacy formatting and typed transaction.
string | $rlp | The RLP-encoded transaction as a binary string. |
BadAddressChecksumException | |
EthBinderLogicException | |
EthBinderRuntimeException | |
InvalidHexException | |
InvalidHexLengthException | |
NotSupportedException |
|
staticinherited |
Decodes a hexadecimal RLP-encoded transaction. Accepts both legacy formatting and typed transaction.
string | $rlp | The RLP-encoded transaction as a hexadecimal string. |
BadAddressChecksumException | |
EthBinderLogicException | |
EthBinderRuntimeException | |
InvalidHexException | |
InvalidHexLengthException | |
NotSupportedException |
|
inherited |
Gets the address where the contract will be deployed if it's deploy transaction. If it is not deploy transaction, it will return null address - Address::NULL()
EthBinderLogicException | |
InvalidLengthException |
M8B\EtherBinder\Common\LegacyTransaction::ecRecover | ( | ) |
Recovers the sender address from the transaction signature.
EthBinderRuntimeException | |
EthBinderLogicException | |
InvalidLengthException |
Reimplemented from M8B\EtherBinder\Common\Transaction.
Reimplemented in M8B\EtherBinder\Common\AccessListTransaction.
M8B\EtherBinder\Common\LegacyTransaction::encodeBin | ( | ) |
Encodes the transaction into a binary blob.
Reimplemented from M8B\EtherBinder\Common\Transaction.
Reimplemented in M8B\EtherBinder\Common\AccessListTransaction.
M8B\EtherBinder\Common\LegacyTransaction::encodeBinForSigning | ( | ?int | $chainId | ) |
Encodes the transaction for signing purposes (which differs from encoding for storage or transfer. Difference is for example missing fields).
int | null | $chainId | The chain ID of the Ethereum network. |
Reimplemented from M8B\EtherBinder\Common\Transaction.
Reimplemented in M8B\EtherBinder\Common\AccessListTransaction.
|
inherited |
Encodes the transaction into a hexadecimal string.
EthBinderArgumentException |
|
inherited |
Encodes the transaction into a hexadecimal string for signing purposes (which differs from encoding for storage or transfer. Difference is for example missing fields).
?int | $chainId | The chain ID for the transaction. |
EthBinderArgumentException |
|
staticinherited |
Alias function for decodeBin()
string | $bin |
BadAddressChecksumException | |
EthBinderLogicException | |
EthBinderRuntimeException | |
InvalidHexException | |
InvalidHexLengthException | |
NotSupportedException |
Implements M8B\EtherBinder\Common\BinarySerializableInterface.
|
staticinherited |
Alias function for decodeHex()
string | $hex |
BadAddressChecksumException | |
EthBinderLogicException | |
EthBinderRuntimeException | |
InvalidHexException | |
InvalidHexLengthException | |
NotSupportedException |
Implements M8B\EtherBinder\Common\BinarySerializableInterface.
|
staticinherited |
Creates a transaction from an RPC array.
array | $rpcArr | The array containing transaction details from RPC. |
BadAddressChecksumException | |
NotSupportedException | |
InvalidHexLengthException | |
EthBinderLogicException | |
InvalidHexException | |
HexBlobNotEvenException |
|
inherited |
Gets the gas limit of the transaction.
|
inherited |
Calculates the hash used for signing the transaction.
int | null | $chainId | Optional chain ID. |
InvalidLengthException | |
EthBinderLogicException |
|
inherited |
Calculates the transaction hash.
EthBinderLogicException |
M8B\EtherBinder\Common\LegacyTransaction::isReplayProtected | ( | ) |
Checks if the transaction is replay-protected (post EIP155).
|
inherited |
Checks if the transaction is signed.
|
inherited |
Gets the nonce of the transaction.
|
inherited |
Convenience function that fetches nonce from RPC and places it into transaction. If new nonce mismatches currently set nonce, it invalidates signature.
Address | $from | Address of which to set next nonce. |
AbstractRPC | $rpc | RPC to query transaction count from. |
EthBinderRuntimeException | |
RPCGeneralException | |
RPCInvalidResponseParamException | |
RPCNotFoundException |
|
inherited |
Gets the ECDSA 'r' value of the signature.
|
inherited |
Gets the ECDSA 's' value of the signature.
|
inherited |
Sets the data payload for the transaction using binary blob. This invalidates signature if data differs from existing data.
string | $dataBin | The binary data. |
|
inherited |
Sets the data for the transaction using a hex string. This invalidates signature if data differs from existing data.
string | $dataHex | Data in hex format. |
HexBlobNotEvenException | |
InvalidHexException |
|
inherited |
Sets the gas limit for the transaction. This invalidates signature if data differs from existing data.
int | $gasLimit | The gas limit value. |
M8B\EtherBinder\Common\LegacyTransaction::setGasPrice | ( | OOGmp | $gasPrice | ) |
Sets the gas price for the transaction.
OOGmp | $gasPrice | The new gas price. |
|
protected |
BadAddressChecksumException | |
EthBinderLogicException | |
InvalidHexLengthException | |
InvalidHexException | |
HexBlobNotEvenException |
Reimplemented from M8B\EtherBinder\Common\Transaction.
Reimplemented in M8B\EtherBinder\Common\AccessListTransaction.
|
inherited |
Sets the nonce for the transaction. This invalidates signature if data differs from existing data.
int | $nonce | The nonce value. |
|
inherited |
Sets the signature. Note that there is no guarantee the signature will work correctly. This is for advanced use only. Ensure to properly account for EIP 155 in signature's V.
|
inherited |
Sets the recipient address for the transaction. If it's null, the transaction is contract deploy transaction. This invalidates signature if data differs from existing data.
Address | null | $address | The Address object or null. If null, the transaction is contract deploy |
|
inherited |
Sets the value for the transaction. This invalidates signature if data differs from existing data.
OOGmp | $valueWEI | The value in Wei. |
|
inherited |
Sets the value for the transaction using WeiFormatter. Accepts "human" input. This invalidates signature if data differs from existing data.
float | int | string | OOGmp | $human | |
int | string | EtherFormats | $format |
|
inherited |
Signs the transaction.
Key | $key | Private key for signing. |
int | null | $chainId | Optional chain ID. |
InvalidLengthException | |
EthBinderLogicException |
|
inherited |
Gets the signature in wrapper object.
|
inherited |
Gets the recipient address of the transaction, null if it's deploy transaction.
|
inherited |
Alias function for encodeBin()
EthBinderArgumentException |
Implements M8B\EtherBinder\Common\BinarySerializableInterface.
|
inherited |
Alias function for encodeHex()
EthBinderArgumentException |
Implements M8B\EtherBinder\Common\BinarySerializableInterface.
|
inherited |
Gets the total gas price for the transaction.
Reimplemented in M8B\EtherBinder\Common\LondonTransaction.
M8B\EtherBinder\Common\LegacyTransaction::transactionType | ( | ) |
Returns the type of the transaction, which is always LEGACY.
Reimplemented from M8B\EtherBinder\Common\Transaction.
|
inherited |
Estimates gas and fee values using from RPC, trying to use conservative values. This invalidates signature if data differs from existing data
AbstractRPC | $rpc | The RPC client. |
Address | $from | The sender address. |
RPCGeneralException | |
RPCNotFoundException | |
RPCInvalidResponseParamException | |
EthBinderLogicException | |
EthBinderRuntimeException |
M8B\EtherBinder\Common\LegacyTransaction::useRpcEstimatesWithBump | ( | AbstractRPC | $rpc, |
?Address | $from, | ||
int | $bumpGasPercentage, | ||
int | $bumpFeePercentage ) |
Uses RPC to estimate gas and fee, then sets them with an optional bump.
AbstractRPC | $rpc | The RPC client. |
Address | null | $from | The sender's address. |
int | $bumpGasPercentage | Percentage to bump the estimated gas. |
int | $bumpFeePercentage | Percentage to bump the estimated fee. |
RPCGeneralException | |
RPCInvalidResponseParamException | |
RPCNotFoundException |
Reimplemented from M8B\EtherBinder\Common\Transaction.
|
inherited |
Gets the ECDSA 'v' value of the signature.
|
inherited |
Gets the value of the transaction.
|
inherited |
Gets the value of the transaction and formats it with WeiFormatter, proxying params to it.
int | $finalDecimals | Number of decimals for formatting. |
int | string | EtherFormats | $format | Ether format. |