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\AccessListTransaction Class Reference
Inheritance diagram for M8B\EtherBinder\Common\AccessListTransaction:
M8B\EtherBinder\Common\LegacyTransaction M8B\EtherBinder\Common\Transaction M8B\EtherBinder\Common\BinarySerializableInterface

Public Member Functions

 calculateV (OOGmp $recovery)
 
 ecRecover ()
 
 accessList ()
 
 setAccessList (array $accessList)
 
 encodeBin ()
 
 encodeBinForSigning (?int $chainId)
 
 transactionType ()
 
 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)
 
 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

 setInnerFromRLPValues (array $rlpValues)
 
 blanksFromRPCArr (array $rpcArr)
 
 setGasPriceOrBaseFee (OOGmp $fee)
 

Protected Attributes

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

Member Function Documentation

◆ accessList()

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

Returns the transaction's access list.

Returns
array The access list.

◆ blanksFromRPCArr()

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

◆ calculateV()

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

@inheritDoc

Reimplemented from M8B\EtherBinder\Common\Transaction.

◆ 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\AccessListTransaction::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\LegacyTransaction.

◆ encodeBin()

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

@inheritDoc

Exceptions
EthBinderArgumentException

Reimplemented from M8B\EtherBinder\Common\LegacyTransaction.

◆ encodeBinForSigning()

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

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

Parameters
int | null$chainIdThe chain ID of the Ethereum network.
Returns
string Binary representation of the transaction for signing.
Exceptions
EthBinderArgumentException

Reimplemented from M8B\EtherBinder\Common\LegacyTransaction.

◆ 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.

◆ 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

◆ isReplayProtected()

M8B\EtherBinder\Common\LegacyTransaction::isReplayProtected ( )
inherited

Checks if the transaction is replay-protected (post EIP155).

Returns
bool True if the transaction is replay-protected, false otherwise.

◆ 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\AccessListTransaction::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

◆ 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

◆ 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.

◆ setGasPrice()

M8B\EtherBinder\Common\LegacyTransaction::setGasPrice ( OOGmp $gasPrice)
inherited

Sets the gas price for the transaction.

Parameters
OOGmp$gasPriceThe new gas price.
Returns
static Returns the instance of the class.

◆ setInnerFromRLPValues()

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

Reimplemented from M8B\EtherBinder\Common\LegacyTransaction.

◆ 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\Transaction::totalGasPrice ( )
inherited

Gets the total gas price for the transaction.

Returns
OOGmp Total gas price.

Reimplemented in M8B\EtherBinder\Common\LondonTransaction.

◆ transactionType()

M8B\EtherBinder\Common\LegacyTransaction::transactionType ( )
inherited

Returns the type of the transaction, which is always LEGACY.

Returns
TransactionType Returns LEGACY as the transaction type.

Reimplemented from M8B\EtherBinder\Common\Transaction.

◆ 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\LegacyTransaction::useRpcEstimatesWithBump ( AbstractRPC $rpc,
?Address $from,
int $bumpGasPercentage,
int $bumpFeePercentage )
inherited

Uses RPC to estimate gas and fee, then sets them with an optional bump.

Parameters
AbstractRPC$rpcThe RPC client.
Address | null$fromThe sender's address.
int$bumpGasPercentagePercentage to bump the estimated gas.
int$bumpFeePercentagePercentage to bump the estimated fee.
Returns
static Returns the instance of the class.
Exceptions
RPCGeneralException
RPCInvalidResponseParamException
RPCNotFoundException

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: