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 | |
encodeBin () | |
encodeBinForSigning (?int $chainId) | |
transactionType () | |
ecRecover () | |
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 |
Transaction serves as an abstract base class for Ethereum transactions. It represents any transaction, can be signed or unsigned.
|
abstractprotected |
Reimplemented in M8B\EtherBinder\Common\CancunTransaction.
M8B\EtherBinder\Common\Transaction::calculateV | ( | OOGmp | $recovery | ) |
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.
M8B\EtherBinder\Common\Transaction::dataBin | ( | ) |
Gets the binary data payload of the transaction.
M8B\EtherBinder\Common\Transaction::dataHex | ( | ) |
Gets the transaction data in hex format.
|
static |
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 |
|
static |
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 |
M8B\EtherBinder\Common\Transaction::deployAddress | ( | ) |
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 |
|
abstract |
EthBinderRuntimeException | |
EthBinderLogicException | |
InvalidLengthException |
Reimplemented in M8B\EtherBinder\Common\AccessListTransaction, M8B\EtherBinder\Common\LegacyTransaction, and M8B\EtherBinder\Common\LondonTransaction.
|
abstract |
EthBinderArgumentException |
Reimplemented in M8B\EtherBinder\Common\AccessListTransaction, M8B\EtherBinder\Common\LegacyTransaction, and M8B\EtherBinder\Common\LondonTransaction.
|
abstract |
EthBinderArgumentException |
Reimplemented in M8B\EtherBinder\Common\AccessListTransaction, M8B\EtherBinder\Common\LegacyTransaction, and M8B\EtherBinder\Common\LondonTransaction.
M8B\EtherBinder\Common\Transaction::encodeHex | ( | ) |
Encodes the transaction into a hexadecimal string.
EthBinderArgumentException |
M8B\EtherBinder\Common\Transaction::encodeHexForSigning | ( | ?int | $chainId | ) |
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 |
|
static |
Alias function for decodeBin()
string | $bin |
BadAddressChecksumException | |
EthBinderLogicException | |
EthBinderRuntimeException | |
InvalidHexException | |
InvalidHexLengthException | |
NotSupportedException |
Implements M8B\EtherBinder\Common\BinarySerializableInterface.
|
static |
Alias function for decodeHex()
string | $hex |
BadAddressChecksumException | |
EthBinderLogicException | |
EthBinderRuntimeException | |
InvalidHexException | |
InvalidHexLengthException | |
NotSupportedException |
Implements M8B\EtherBinder\Common\BinarySerializableInterface.
|
static |
Creates a transaction from an RPC array.
array | $rpcArr | The array containing transaction details from RPC. |
BadAddressChecksumException | |
NotSupportedException | |
InvalidHexLengthException | |
EthBinderLogicException | |
InvalidHexException | |
HexBlobNotEvenException |
M8B\EtherBinder\Common\Transaction::gasLimit | ( | ) |
Gets the gas limit of the transaction.
M8B\EtherBinder\Common\Transaction::getSigningHash | ( | ?int | $chainId | ) |
Calculates the hash used for signing the transaction.
int | null | $chainId | Optional chain ID. |
InvalidLengthException | |
EthBinderLogicException |
M8B\EtherBinder\Common\Transaction::hash | ( | ) |
Calculates the transaction hash.
EthBinderLogicException |
M8B\EtherBinder\Common\Transaction::isSigned | ( | ) |
Checks if the transaction is signed.
M8B\EtherBinder\Common\Transaction::nonce | ( | ) |
Gets the nonce of the transaction.
M8B\EtherBinder\Common\Transaction::nonceFromRPC | ( | Address | $from, |
AbstractRPC | $rpc ) |
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 |
M8B\EtherBinder\Common\Transaction::r | ( | ) |
Gets the ECDSA 'r' value of the signature.
M8B\EtherBinder\Common\Transaction::s | ( | ) |
Gets the ECDSA 's' value of the signature.
M8B\EtherBinder\Common\Transaction::setDataBin | ( | string | $dataBin | ) |
Sets the data payload for the transaction using binary blob. This invalidates signature if data differs from existing data.
string | $dataBin | The binary data. |
M8B\EtherBinder\Common\Transaction::setDataHex | ( | string | $dataHex | ) |
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 |
M8B\EtherBinder\Common\Transaction::setGasLimit | ( | int | $gasLimit | ) |
Sets the gas limit for the transaction. This invalidates signature if data differs from existing data.
int | $gasLimit | The gas limit value. |
|
abstractprotected |
BadAddressChecksumException | |
EthBinderLogicException | |
InvalidHexLengthException | |
InvalidHexException | |
EthBinderRuntimeException |
Reimplemented in M8B\EtherBinder\Common\AccessListTransaction, M8B\EtherBinder\Common\CancunTransaction, M8B\EtherBinder\Common\LegacyTransaction, and M8B\EtherBinder\Common\LondonTransaction.
M8B\EtherBinder\Common\Transaction::setNonce | ( | int | $nonce | ) |
Sets the nonce for the transaction. This invalidates signature if data differs from existing data.
int | $nonce | The nonce value. |
M8B\EtherBinder\Common\Transaction::setSignature | ( | Signature | $s | ) |
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.
M8B\EtherBinder\Common\Transaction::setTo | ( | ?Address | $address | ) |
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 |
M8B\EtherBinder\Common\Transaction::setValue | ( | OOGmp | $valueWEI | ) |
Sets the value for the transaction. This invalidates signature if data differs from existing data.
OOGmp | $valueWEI | The value in Wei. |
M8B\EtherBinder\Common\Transaction::setValueFmt | ( | float|int|string|OOGmp | $human, |
int|string|EtherFormats | $format = EtherFormats::ETHER ) |
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 |
M8B\EtherBinder\Common\Transaction::sign | ( | Key | $key, |
?int | $chainId ) |
Signs the transaction.
Key | $key | Private key for signing. |
int | null | $chainId | Optional chain ID. |
InvalidLengthException | |
EthBinderLogicException |
M8B\EtherBinder\Common\Transaction::signature | ( | ) |
Gets the signature in wrapper object.
M8B\EtherBinder\Common\Transaction::to | ( | ) |
Gets the recipient address of the transaction, null if it's deploy transaction.
M8B\EtherBinder\Common\Transaction::toBin | ( | ) |
Alias function for encodeBin()
EthBinderArgumentException |
Implements M8B\EtherBinder\Common\BinarySerializableInterface.
M8B\EtherBinder\Common\Transaction::toHex | ( | ) |
Alias function for encodeHex()
EthBinderArgumentException |
Implements M8B\EtherBinder\Common\BinarySerializableInterface.
M8B\EtherBinder\Common\Transaction::totalGasPrice | ( | ) |
Gets the total gas price for the transaction.
Reimplemented in M8B\EtherBinder\Common\LondonTransaction.
|
abstract |
M8B\EtherBinder\Common\Transaction::useRpcEstimates | ( | AbstractRPC | $rpc, |
Address | $from ) |
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 |
|
abstract |
RPCGeneralException | |
RPCNotFoundException | |
EthBinderLogicException | |
RPCInvalidResponseParamException | |
EthBinderRuntimeException |
Reimplemented in M8B\EtherBinder\Common\LegacyTransaction, and M8B\EtherBinder\Common\LondonTransaction.
M8B\EtherBinder\Common\Transaction::v | ( | ) |
Gets the ECDSA 'v' value of the signature.
M8B\EtherBinder\Common\Transaction::value | ( | ) |
Gets the value of the transaction.
M8B\EtherBinder\Common\Transaction::valueFmt | ( | int | $finalDecimals, |
int|string|EtherFormats | $format = EtherFormats::ETHER ) |
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. |