Ether Binder
Set of utilities for interacting with Ethereum and it's smart contracts with PHP, with generating ABI bindings and Ethereum-related types
Loading...
Searching...
No Matches
M8B\EtherBinder\Common\LondonTransaction Class Reference
Inheritance diagram for M8B\EtherBinder\Common\LondonTransaction:
M8B\EtherBinder\Common\Transaction M8B\EtherBinder\Common\BinarySerializableInterface M8B\EtherBinder\Common\CancunTransaction

Public Member Functions

 encodeBinForSigning (?int $chainId)
 
 encodeBin ()
 
 transactionType ()
 
 totalGasPrice ()
 
 ecRecover ()
 
 accessList ()
 
 setAccessList (array $accessList)
 
 chainId ()
 
 setChainId (int $chainId)
 
 getBaseFeeCap ()
 
 setBaseFeeCap (OOGmp $fee)
 
 getGasFeeTip ()
 
 setGasFeeTip (OOGmp $gasFeeTip)
 
 useRpcEstimatesWithBump (AbstractRPC $rpc, ?Address $from, int $bumpGasPercentage, int $bumpFeePercentage)
 
 calculateV (OOGmp $recovery)
 
 toBin ()
 
 toHex ()
 
 encodeHexForSigning (?int $chainId)
 
 encodeHex ()
 
 setNonce (int $nonce)
 
 nonce ()
 
 setGasLimit (int $gasLimit)
 
 gasLimit ()
 
 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)
 
 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

 internalEncodeBin (bool $signing, ?int $signingChainID)
 
 blanksFromRPCArr (array $rpcArr)
 
 setInnerFromRLPValues (array $rlpValues)
 
 setGasPriceOrBaseFee (OOGmp $fee)
 

Protected Attributes

array $accessList = []
 
OOGmp $gasFeeTip
 
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
 

Detailed Description

LondonTransaction handles Ethereum transactions post EIP-1559.

Author
DubbaThony

Constructor & Destructor Documentation

◆ __construct()

M8B\EtherBinder\Common\LondonTransaction::__construct ( )

Member Function Documentation

◆ accessList()

M8B\EtherBinder\Common\LondonTransaction::accessList ( )

Returns the transaction's access list.

Returns
array The access list.

◆ blanksFromRPCArr()

M8B\EtherBinder\Common\LondonTransaction::blanksFromRPCArr ( array $rpcArr)
protected

◆ calculateV()

M8B\EtherBinder\Common\LondonTransaction::calculateV ( OOGmp $recovery)

in typed transactions, the chainID is part of transaction data, and V is "vanilla" ECDSA signature recovery param, without any alteration. See https://eips.ethereum.org/EIPS/eip-2930 @inheritDoc

Reimplemented from M8B\EtherBinder\Common\Transaction.

◆ chainId()

M8B\EtherBinder\Common\LondonTransaction::chainId ( )

Returns the chain ID for the transaction.

Returns
int The chain ID.

◆ dataBin()

M8B\EtherBinder\Common\Transaction::dataBin ( )
inherited

Gets the binary data payload of the transaction.

Returns
string The binary data.

◆ dataHex()

M8B\EtherBinder\Common\Transaction::dataHex ( )
inherited

Gets the transaction data in hex format.

Returns
string Data in hex.

◆ decodeBin()

static M8B\EtherBinder\Common\Transaction::decodeBin ( string $rlp)
staticinherited

Decodes a binary RLP-encoded transaction. Accepts both legacy formatting and typed transaction.

Parameters
string$rlpThe RLP-encoded transaction as a binary string.
Returns
static The decoded Transaction object.
Exceptions
BadAddressChecksumException
EthBinderLogicException
EthBinderRuntimeException
InvalidHexException
InvalidHexLengthException
NotSupportedException

◆ decodeHex()

static M8B\EtherBinder\Common\Transaction::decodeHex ( string $rlp)
staticinherited

Decodes a hexadecimal RLP-encoded transaction. Accepts both legacy formatting and typed transaction.

Parameters
string$rlpThe RLP-encoded transaction as a hexadecimal string.
Returns
static The decoded Transaction object.
Exceptions
BadAddressChecksumException
EthBinderLogicException
EthBinderRuntimeException
InvalidHexException
InvalidHexLengthException
NotSupportedException

◆ deployAddress()

M8B\EtherBinder\Common\Transaction::deployAddress ( )
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()

Returns
Address Address where contract will be deployed.
Exceptions
EthBinderLogicException
InvalidLengthException

◆ ecRecover()

M8B\EtherBinder\Common\LondonTransaction::ecRecover ( )

Recovers the address of the signer from the signature. Returns null address if is not signed.

Returns
Address The address of the signer.
Exceptions
EthBinderRuntimeException
EthBinderLogicException
InvalidLengthException

Reimplemented from M8B\EtherBinder\Common\Transaction.

◆ encodeBin()

M8B\EtherBinder\Common\LondonTransaction::encodeBin ( )

RLP-encodes the transaction into binary format.

Returns
string The encoded transaction.
Exceptions
EthBinderArgumentException

Reimplemented from M8B\EtherBinder\Common\Transaction.

◆ encodeBinForSigning()

M8B\EtherBinder\Common\LondonTransaction::encodeBinForSigning ( ?int $chainId)

Encodes the transaction for signing with optional chain ID (which differs from encoding for storage or transfer. Difference is for example missing fields).

Parameters
int | null$chainIdThe chain ID to use for signing. If null, the transaction's current chain ID will be used.
Returns
string The encoded transaction.
Exceptions
EthBinderArgumentException

Reimplemented from M8B\EtherBinder\Common\Transaction.

◆ encodeHex()

M8B\EtherBinder\Common\Transaction::encodeHex ( )
inherited

Encodes the transaction into a hexadecimal string.

Returns
string The hexadecimal encoded transaction.
Exceptions
EthBinderArgumentException

◆ encodeHexForSigning()

M8B\EtherBinder\Common\Transaction::encodeHexForSigning ( ?int $chainId)
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).

Parameters
?int$chainIdThe chain ID for the transaction.
Returns
string The hexadecimal encoded transaction.
Exceptions
EthBinderArgumentException

◆ fromBin()

static M8B\EtherBinder\Common\Transaction::fromBin ( string $bin)
staticinherited

Alias function for decodeBin()

See also
static::decodeBin()
Parameters
string$bin
Returns
static
Exceptions
BadAddressChecksumException
EthBinderLogicException
EthBinderRuntimeException
InvalidHexException
InvalidHexLengthException
NotSupportedException

Implements M8B\EtherBinder\Common\BinarySerializableInterface.

◆ fromHex()

static M8B\EtherBinder\Common\Transaction::fromHex ( string $hex)
staticinherited

Alias function for decodeHex()

See also
static::decodeHex()
Parameters
string$hex
Returns
static
Exceptions
BadAddressChecksumException
EthBinderLogicException
EthBinderRuntimeException
InvalidHexException
InvalidHexLengthException
NotSupportedException

Implements M8B\EtherBinder\Common\BinarySerializableInterface.

◆ fromRPCArr()

static M8B\EtherBinder\Common\Transaction::fromRPCArr ( array $rpcArr)
staticinherited

Creates a transaction from an RPC array.

Parameters
array$rpcArrThe array containing transaction details from RPC.
Returns
static The created Transaction object.
Exceptions
BadAddressChecksumException
NotSupportedException
InvalidHexLengthException
EthBinderLogicException
InvalidHexException
HexBlobNotEvenException

◆ gasLimit()

M8B\EtherBinder\Common\Transaction::gasLimit ( )
inherited

Gets the gas limit of the transaction.

Returns
int The gas limit value.

◆ getBaseFeeCap()

M8B\EtherBinder\Common\LondonTransaction::getBaseFeeCap ( )

Returns the base fee cap.

Returns
OOGmp The base fee cap.

◆ getGasFeeTip()

M8B\EtherBinder\Common\LondonTransaction::getGasFeeTip ( )

Gets the gas fee tip.

Returns
OOGmp The gas fee tip.

◆ getSigningHash()

M8B\EtherBinder\Common\Transaction::getSigningHash ( ?int $chainId)
inherited

Calculates the hash used for signing the transaction.

Parameters
int | null$chainIdOptional chain ID.
Returns
Hash The signing hash.
Exceptions
InvalidLengthException
EthBinderLogicException

◆ hash()

M8B\EtherBinder\Common\Transaction::hash ( )
inherited

Calculates the transaction hash.

Returns
Hash The transaction hash.
Exceptions
EthBinderLogicException

◆ internalEncodeBin()

M8B\EtherBinder\Common\LondonTransaction::internalEncodeBin ( bool $signing,
?int $signingChainID )
protected
Exceptions
EthBinderArgumentException

Reimplemented in M8B\EtherBinder\Common\CancunTransaction.

◆ isSigned()

M8B\EtherBinder\Common\Transaction::isSigned ( )
inherited

Checks if the transaction is signed.

Returns
bool True if signed, false otherwise.

◆ nonce()

M8B\EtherBinder\Common\Transaction::nonce ( )
inherited

Gets the nonce of the transaction.

Returns
int The nonce value.

◆ nonceFromRPC()

M8B\EtherBinder\Common\Transaction::nonceFromRPC ( Address $from,
AbstractRPC $rpc )
inherited

Convenience function that fetches nonce from RPC and places it into transaction. If new nonce mismatches currently set nonce, it invalidates signature.

Parameters
Address$fromAddress of which to set next nonce.
AbstractRPC$rpcRPC to query transaction count from.
Returns
Transaction self for chainable API.
Exceptions
EthBinderRuntimeException
RPCGeneralException
RPCInvalidResponseParamException
RPCNotFoundException

◆ r()

M8B\EtherBinder\Common\Transaction::r ( )
inherited

Gets the ECDSA 'r' value of the signature.

Returns
OOGmp The 'r' value.

◆ s()

M8B\EtherBinder\Common\Transaction::s ( )
inherited

Gets the ECDSA 's' value of the signature.

Returns
OOGmp The 's' value.

◆ setAccessList()

M8B\EtherBinder\Common\LondonTransaction::setAccessList ( array $accessList)

Sets the access list for the transaction. This invalidates signature if data differs from existing data.

Parameters
array$accessListThe new access list.
Returns
static

◆ setBaseFeeCap()

M8B\EtherBinder\Common\LondonTransaction::setBaseFeeCap ( OOGmp $fee)

Sets the base fee cap for the transaction. This invalidates signature if data differs from existing data.

Parameters
OOGmp$feeThe new base fee cap.
Returns
static

◆ setChainId()

M8B\EtherBinder\Common\LondonTransaction::setChainId ( int $chainId)

Sets the chain ID for the transaction. This invalidates signature if data differs from existing data.

Parameters
int$chainIdThe new chain ID.
Returns
static

◆ setDataBin()

M8B\EtherBinder\Common\Transaction::setDataBin ( string $dataBin)
inherited

Sets the data payload for the transaction using binary blob. This invalidates signature if data differs from existing data.

Parameters
string$dataBinThe binary data.
Returns
static The updated Transaction object.

◆ setDataHex()

M8B\EtherBinder\Common\Transaction::setDataHex ( string $dataHex)
inherited

Sets the data for the transaction using a hex string. This invalidates signature if data differs from existing data.

Parameters
string$dataHexData in hex format.
Returns
static
Exceptions
HexBlobNotEvenException
InvalidHexException

◆ setGasFeeTip()

M8B\EtherBinder\Common\LondonTransaction::setGasFeeTip ( OOGmp $gasFeeTip)

Sets the gas fee tip for the transaction. This invalidates signature if data differs from existing data.

Parameters
OOGmp$gasFeeTipThe new gas fee tip.
Returns
static

◆ setGasLimit()

M8B\EtherBinder\Common\Transaction::setGasLimit ( int $gasLimit)
inherited

Sets the gas limit for the transaction. This invalidates signature if data differs from existing data.

Parameters
int$gasLimitThe gas limit value.
Returns
static The updated Transaction object.

◆ setInnerFromRLPValues()

M8B\EtherBinder\Common\LondonTransaction::setInnerFromRLPValues ( array $rlpValues)
protected
Exceptions
BadAddressChecksumException
EthBinderLogicException
InvalidHexLengthException
InvalidHexException
HexBlobNotEvenException

Reimplemented from M8B\EtherBinder\Common\Transaction.

Reimplemented in M8B\EtherBinder\Common\CancunTransaction.

◆ setNonce()

M8B\EtherBinder\Common\Transaction::setNonce ( int $nonce)
inherited

Sets the nonce for the transaction. This invalidates signature if data differs from existing data.

Parameters
int$nonceThe nonce value.
Returns
static The updated Transaction object.

◆ setSignature()

M8B\EtherBinder\Common\Transaction::setSignature ( Signature $s)
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.

Returns
static The updated Transaction object.

◆ setTo()

M8B\EtherBinder\Common\Transaction::setTo ( ?Address $address)
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.

Parameters
Address | null$addressThe Address object or null. If null, the transaction is contract deploy
Returns
static The updated Transaction object.

◆ setValue()

M8B\EtherBinder\Common\Transaction::setValue ( OOGmp $valueWEI)
inherited

Sets the value for the transaction. This invalidates signature if data differs from existing data.

Parameters
OOGmp$valueWEIThe value in Wei.
Returns
static The updated Transaction object.

◆ setValueFmt()

M8B\EtherBinder\Common\Transaction::setValueFmt ( float|int|string|OOGmp $human,
int|string|EtherFormats $format = EtherFormats::ETHER )
inherited

Sets the value for the transaction using WeiFormatter. Accepts "human" input. This invalidates signature if data differs from existing data.

Parameters
float | int | string | OOGmp$human
int | string | EtherFormats$format
Returns
static The updated Transaction object.

◆ sign()

M8B\EtherBinder\Common\Transaction::sign ( Key $key,
?int $chainId )
inherited

Signs the transaction.

Parameters
Key$keyPrivate key for signing.
int | null$chainIdOptional chain ID.
Returns
static
Exceptions
InvalidLengthException
EthBinderLogicException

◆ signature()

M8B\EtherBinder\Common\Transaction::signature ( )
inherited

Gets the signature in wrapper object.

Returns
Signature The signature details.

◆ to()

M8B\EtherBinder\Common\Transaction::to ( )
inherited

Gets the recipient address of the transaction, null if it's deploy transaction.

Returns
Address|null The recipient address or null (deploy).

◆ toBin()

M8B\EtherBinder\Common\Transaction::toBin ( )
inherited

Alias function for encodeBin()

Returns
string
Exceptions
EthBinderArgumentException
See also
static::encodeBin()

Implements M8B\EtherBinder\Common\BinarySerializableInterface.

◆ toHex()

M8B\EtherBinder\Common\Transaction::toHex ( )
inherited

Alias function for encodeHex()

See also
static::encodeHex()
Returns
string
Exceptions
EthBinderArgumentException

Implements M8B\EtherBinder\Common\BinarySerializableInterface.

◆ totalGasPrice()

M8B\EtherBinder\Common\LondonTransaction::totalGasPrice ( )

Calculates the total gas price for the transaction of both tip and base fee.

Returns
OOGmp The total gas price.

Reimplemented from M8B\EtherBinder\Common\Transaction.

◆ transactionType()

M8B\EtherBinder\Common\LondonTransaction::transactionType ( )

Returns the transaction type enum.

Returns
TransactionType The transaction type enum value.

Reimplemented from M8B\EtherBinder\Common\Transaction.

Reimplemented in M8B\EtherBinder\Common\CancunTransaction.

◆ useRpcEstimates()

M8B\EtherBinder\Common\Transaction::useRpcEstimates ( AbstractRPC $rpc,
Address $from )
inherited

Estimates gas and fee values using from RPC, trying to use conservative values. This invalidates signature if data differs from existing data

Parameters
AbstractRPC$rpcThe RPC client.
Address$fromThe sender address.
Returns
static The updated Transaction object.
Exceptions
RPCGeneralException
RPCNotFoundException
RPCInvalidResponseParamException
EthBinderLogicException
EthBinderRuntimeException

◆ useRpcEstimatesWithBump()

M8B\EtherBinder\Common\LondonTransaction::useRpcEstimatesWithBump ( AbstractRPC $rpc,
?Address $from,
int $bumpGasPercentage,
int $bumpFeePercentage )

Updates the transaction gas and fee estimates using RPC, with added N percent "bump". Note that percentage is added, so if 120% of minimal value is required, param should be 20, not 120. This invalidates signature if data differs from existing data.

Parameters
AbstractRPC$rpcThe RPC client.
Address | null$fromThe sender's address.
int$bumpGasPercentageIncrease in gas limit as a percentage.
int$bumpFeePercentageIncrease in fee as a percentage.
Returns
static
Exceptions
EthBinderLogicException
RPCInvalidResponseParamException
RPCGeneralException
RPCNotFoundException
EthBinderRuntimeException

Reimplemented from M8B\EtherBinder\Common\Transaction.

◆ v()

M8B\EtherBinder\Common\Transaction::v ( )
inherited

Gets the ECDSA 'v' value of the signature.

Returns
OOGmp The 'v' value.

◆ value()

M8B\EtherBinder\Common\Transaction::value ( )
inherited

Gets the value of the transaction.

Returns
OOGmp The value in Wei.

◆ valueFmt()

M8B\EtherBinder\Common\Transaction::valueFmt ( int $finalDecimals,
int|string|EtherFormats $format = EtherFormats::ETHER )
inherited

Gets the value of the transaction and formats it with WeiFormatter, proxying params to it.

Parameters
int$finalDecimalsNumber of decimals for formatting.
int | string | EtherFormats$formatEther format.
Returns
string Formatted value.

The documentation for this class was generated from the following file: