LondonTransaction
extends Transaction
in package
LondonTransaction handles Ethereum transactions post EIP-1559.
Tags
Table of Contents
Properties
- $accessList : array<string|int, mixed>
- $chainId : int|null
- $dataBin : string
- $gas : int
- $gasFeeTip : OOGmp
- $gasPrice : OOGmp
- $nonce : int
- $r : OOGmp
- $s : OOGmp
- $signed : bool
- $to : Address|null
- $v : OOGmp
- $value : OOGmp
Methods
- __construct() : mixed
- accessList() : array<string|int, mixed>
- Returns the transaction's access list.
- calculateV() : OOGmp
- 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
- chainId() : int
- Returns the chain ID for the transaction.
- dataBin() : string
- Gets the binary data payload of the transaction.
- dataHex() : string
- Gets the transaction data in hex format.
- decodeBin() : static
- Decodes a binary RLP-encoded transaction. Accepts both legacy formatting and typed transaction.
- decodeHex() : static
- Decodes a hexadecimal RLP-encoded transaction. Accepts both legacy formatting and typed transaction.
- deployAddress() : Address
- 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()
- ecRecover() : Address
- Recovers the address of the signer from the signature. Returns null address if is not signed.
- encodeBin() : string
- RLP-encodes the transaction into binary format.
- encodeBinForSigning() : string
- Encodes the transaction for signing with optional chain ID (which differs from encoding for storage or transfer. Difference is for example missing fields).
- encodeHex() : string
- Encodes the transaction into a hexadecimal string.
- encodeHexForSigning() : string
- Encodes the transaction into a hexadecimal string for signing purposes (which differs from encoding for storage or transfer. Difference is for example missing fields).
- fromBin() : static
- Alias function for decodeBin()
- fromHex() : static
- Alias function for decodeHex()
- fromRPCArr() : static
- Creates a transaction from an RPC array.
- gasLimit() : int
- Gets the gas limit of the transaction.
- getBaseFeeCap() : OOGmp
- Returns the base fee cap.
- getGasFeeTip() : OOGmp
- Gets the gas fee tip.
- getSigningHash() : Hash
- Calculates the hash used for signing the transaction.
- hash() : Hash
- Calculates the transaction hash.
- isSigned() : bool
- Checks if the transaction is signed.
- nonce() : int
- Gets the nonce of the transaction.
- nonceFromRPC() : Transaction
- Convenience function that fetches nonce from RPC and places it into transaction.
- r() : OOGmp
- Gets the ECDSA 'r' value of the signature.
- s() : OOGmp
- Gets the ECDSA 's' value of the signature.
- setAccessList() : static
- Sets the access list for the transaction.
- setBaseFeeCap() : static
- Sets the base fee cap for the transaction.
- setChainId() : static
- Sets the chain ID for the transaction.
- setDataBin() : static
- Sets the data payload for the transaction using binary blob.
- setDataHex() : static
- Sets the data for the transaction using a hex string.
- setGasFeeTip() : static
- Sets the gas fee tip for the transaction.
- setGasLimit() : static
- Sets the gas limit for the transaction.
- setNonce() : static
- Sets the nonce for the transaction.
- setSignature() : static
- Sets the signature. Note that there is no guarantee the signature will work correctly.
- setTo() : static
- Sets the recipient address for the transaction. If it's null, the transaction is contract deploy transaction.
- setValue() : static
- Sets the value for the transaction.
- setValueFmt() : static
- Sets the value for the transaction using WeiFormatter. Accepts "human" input.
- sign() : static
- Signs the transaction.
- signature() : Signature
- Gets the signature in wrapper object.
- to() : Address|null
- Gets the recipient address of the transaction, null if it's deploy transaction.
- toBin() : string
- Alias function for encodeBin()
- toHex() : string
- Alias function for encodeHex()
- totalGasPrice() : OOGmp
- Calculates the total gas price for the transaction of both tip and base fee.
- transactionType() : TransactionType
- Returns the transaction type enum.
- useRpcEstimates() : static
- Estimates gas and fee values using from RPC, trying to use conservative values.
- useRpcEstimatesWithBump() : static
- 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.
- v() : OOGmp
- Gets the ECDSA 'v' value of the signature.
- value() : OOGmp
- Gets the value of the transaction.
- valueFmt() : string
- Gets the value of the transaction and formats it with WeiFormatter, proxying params to it.
- blanksFromRPCArr() : void
- internalEncodeBin() : string
- setGasPriceOrBaseFee() : static
- setInnerFromRLPValues() : void
Properties
$accessList
protected
array<string|int, mixed>
$accessList
= []
$chainId
protected
int|null
$chainId
= null
$dataBin
protected
string
$dataBin
= ""
$gas
protected
int
$gas
= 0
$gasFeeTip
protected
OOGmp
$gasFeeTip
$gasPrice
protected
OOGmp
$gasPrice
$nonce
protected
int
$nonce
= 0
$r
protected
OOGmp
$r
$s
protected
OOGmp
$s
$signed
protected
bool
$signed
= false
$to
protected
Address|null
$to
= null
$v
protected
OOGmp
$v
$value
protected
OOGmp
$value
Methods
__construct()
public
__construct() : mixed
accessList()
Returns the transaction's access list.
public
accessList() : array<string|int, mixed>
@return array The access list.
Return values
array<string|int, mixed>calculateV()
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
public
calculateV(OOGmp $recovery) : OOGmp
Parameters
- $recovery : OOGmp
-
Recovery id before chain id calculations.
Tags
Return values
OOGmp —Final recovery id.
chainId()
Returns the chain ID for the transaction.
public
chainId() : int
@return int The chain ID.
Return values
intdataBin()
Gets the binary data payload of the transaction.
public
dataBin() : string
Return values
string —The binary data.
dataHex()
Gets the transaction data in hex format.
public
dataHex() : string
Return values
string —Data in hex.
decodeBin()
Decodes a binary RLP-encoded transaction. Accepts both legacy formatting and typed transaction.
public
static decodeBin(string $rlp) : static
Parameters
- $rlp : string
-
The RLP-encoded transaction as a binary string.
Tags
Return values
static —The decoded Transaction object.
decodeHex()
Decodes a hexadecimal RLP-encoded transaction. Accepts both legacy formatting and typed transaction.
public
static decodeHex(string $rlp) : static
Parameters
- $rlp : string
-
The RLP-encoded transaction as a hexadecimal string.
Tags
Return values
static —The decoded Transaction object.
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()
public
deployAddress() : Address
Tags
Return values
Address —Address where contract will be deployed.
ecRecover()
Recovers the address of the signer from the signature. Returns null address if is not signed.
public
ecRecover() : Address
@return Address The address of the signer.
Tags
Return values
AddressencodeBin()
RLP-encodes the transaction into binary format.
public
encodeBin() : string
Tags
Return values
string —The encoded transaction.
encodeBinForSigning()
Encodes the transaction for signing with optional chain ID (which differs from encoding for storage or transfer. Difference is for example missing fields).
public
encodeBinForSigning(int|null $chainId) : string
Parameters
- $chainId : int|null
-
The chain ID to use for signing. If null, the transaction's current chain ID will be used.
Tags
Return values
string —The encoded transaction.
encodeHex()
Encodes the transaction into a hexadecimal string.
public
encodeHex() : string
Tags
Return values
string —The hexadecimal encoded transaction.
encodeHexForSigning()
Encodes the transaction into a hexadecimal string for signing purposes (which differs from encoding for storage or transfer. Difference is for example missing fields).
public
encodeHexForSigning(int|null $chainId) : string
Parameters
- $chainId : int|null
-
The chain ID for the transaction.
Tags
Return values
string —The hexadecimal encoded transaction.
fromBin()
Alias function for decodeBin()
public
static fromBin(string $bin) : static
Parameters
- $bin : string
Tags
Return values
staticfromHex()
Alias function for decodeHex()
public
static fromHex(string $hex) : static
Parameters
- $hex : string
Tags
Return values
staticfromRPCArr()
Creates a transaction from an RPC array.
public
static fromRPCArr(array<string|int, mixed> $rpcArr) : static
Parameters
- $rpcArr : array<string|int, mixed>
-
The array containing transaction details from RPC.
Tags
Return values
static —The created Transaction object.
gasLimit()
Gets the gas limit of the transaction.
public
gasLimit() : int
Return values
int —The gas limit value.
getBaseFeeCap()
Returns the base fee cap.
public
getBaseFeeCap() : OOGmp
@return OOGmp The base fee cap.
Return values
OOGmpgetGasFeeTip()
Gets the gas fee tip.
public
getGasFeeTip() : OOGmp
@return OOGmp The gas fee tip.
Return values
OOGmpgetSigningHash()
Calculates the hash used for signing the transaction.
public
getSigningHash(int|null $chainId) : Hash
Parameters
- $chainId : int|null
-
Optional chain ID.
Tags
Return values
Hash —The signing hash.
hash()
Calculates the transaction hash.
public
hash() : Hash
Tags
Return values
Hash —The transaction hash.
isSigned()
Checks if the transaction is signed.
public
isSigned() : bool
Return values
bool —True if signed, false otherwise.
nonce()
Gets the nonce of the transaction.
public
nonce() : int
Return values
int —The nonce value.
nonceFromRPC()
Convenience function that fetches nonce from RPC and places it into transaction.
public
nonceFromRPC(Address $from, AbstractRPC $rpc) : Transaction
If new nonce mismatches currently set nonce, it invalidates signature.
Parameters
- $from : Address
-
Address of which to set next nonce.
- $rpc : AbstractRPC
-
RPC to query transaction count from.
Tags
Return values
Transaction —self for chainable API.
r()
Gets the ECDSA 'r' value of the signature.
public
r() : OOGmp
Return values
OOGmp —The 'r' value.
s()
Gets the ECDSA 's' value of the signature.
public
s() : OOGmp
Return values
OOGmp —The 's' value.
setAccessList()
Sets the access list for the transaction.
public
setAccessList(array<string|int, mixed> $accessList) : static
This invalidates signature if data differs from existing data.
Parameters
- $accessList : array<string|int, mixed>
-
The new access list. @return static
Return values
staticsetBaseFeeCap()
Sets the base fee cap for the transaction.
public
setBaseFeeCap(OOGmp $fee) : static
This invalidates signature if data differs from existing data.
Parameters
- $fee : OOGmp
-
The new base fee cap.
Return values
staticsetChainId()
Sets the chain ID for the transaction.
public
setChainId(int $chainId) : static
This invalidates signature if data differs from existing data.
Parameters
- $chainId : int
-
The new chain ID. @return static
Return values
staticsetDataBin()
Sets the data payload for the transaction using binary blob.
public
setDataBin(string $dataBin) : static
This invalidates signature if data differs from existing data.
Parameters
- $dataBin : string
-
The binary data.
Return values
static —The updated Transaction object.
setDataHex()
Sets the data for the transaction using a hex string.
public
setDataHex(string $dataHex) : static
This invalidates signature if data differs from existing data.
Parameters
- $dataHex : string
-
Data in hex format.
Tags
Return values
staticsetGasFeeTip()
Sets the gas fee tip for the transaction.
public
setGasFeeTip(OOGmp $gasFeeTip) : static
This invalidates signature if data differs from existing data.
Parameters
- $gasFeeTip : OOGmp
-
The new gas fee tip.
Return values
staticsetGasLimit()
Sets the gas limit for the transaction.
public
setGasLimit(int $gasLimit) : static
This invalidates signature if data differs from existing data.
Parameters
- $gasLimit : int
-
The gas limit value.
Return values
static —The updated Transaction object.
setNonce()
Sets the nonce for the transaction.
public
setNonce(int $nonce) : static
This invalidates signature if data differs from existing data.
Parameters
- $nonce : int
-
The nonce value.
Return values
static —The updated Transaction object.
setSignature()
Sets the signature. Note that there is no guarantee the signature will work correctly.
public
setSignature(Signature $s) : static
This is for advanced use only. Ensure to properly account for EIP 155 in signature's V.
Parameters
- $s : Signature
Return values
static —The updated Transaction object.
setTo()
Sets the recipient address for the transaction. If it's null, the transaction is contract deploy transaction.
public
setTo(Address|null $address) : static
This invalidates signature if data differs from existing data.
Parameters
- $address : Address|null
-
The Address object or null. If null, the transaction is contract deploy
Return values
static —The updated Transaction object.
setValue()
Sets the value for the transaction.
public
setValue(OOGmp $valueWEI) : static
This invalidates signature if data differs from existing data.
Parameters
- $valueWEI : OOGmp
-
The value in Wei.
Return values
static —The updated Transaction object.
setValueFmt()
Sets the value for the transaction using WeiFormatter. Accepts "human" input.
public
setValueFmt(float|int|string|OOGmp $human[, int|string|EtherFormats $format = EtherFormats::ETHER ]) : static
This invalidates signature if data differs from existing data.
Parameters
- $human : float|int|string|OOGmp
- $format : int|string|EtherFormats = EtherFormats::ETHER
Return values
static —The updated Transaction object.
sign()
Signs the transaction.
public
sign(Key $key, int|null $chainId) : static
Parameters
- $key : Key
-
Private key for signing.
- $chainId : int|null
-
Optional chain ID.
Tags
Return values
staticsignature()
Gets the signature in wrapper object.
public
signature() : Signature
Return values
Signature —The signature details.
to()
Gets the recipient address of the transaction, null if it's deploy transaction.
public
to() : Address|null
Return values
Address|null —The recipient address or null (deploy).
toBin()
Alias function for encodeBin()
public
toBin() : string
Tags
Return values
stringtoHex()
Alias function for encodeHex()
public
toHex() : string
Tags
Return values
stringtotalGasPrice()
Calculates the total gas price for the transaction of both tip and base fee.
public
totalGasPrice() : OOGmp
@return OOGmp The total gas price.
Return values
OOGmp —Total gas price.
transactionType()
Returns the transaction type enum.
public
transactionType() : TransactionType
@return TransactionType The transaction type enum value.
Return values
TransactionTypeuseRpcEstimates()
Estimates gas and fee values using from RPC, trying to use conservative values.
public
useRpcEstimates(AbstractRPC $rpc, Address $from) : static
This invalidates signature if data differs from existing data
Parameters
- $rpc : AbstractRPC
-
The RPC client.
- $from : Address
-
The sender address.
Tags
Return values
static —The updated Transaction object.
useRpcEstimatesWithBump()
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.
public
useRpcEstimatesWithBump(AbstractRPC $rpc, Address|null $from, int $bumpGasPercentage, int $bumpFeePercentage) : static
This invalidates signature if data differs from existing data.
Parameters
- $rpc : AbstractRPC
-
The RPC client.
- $from : Address|null
-
The sender's address.
- $bumpGasPercentage : int
-
Increase in gas limit as a percentage.
- $bumpFeePercentage : int
-
Increase in fee as a percentage.
Tags
Return values
staticv()
Gets the ECDSA 'v' value of the signature.
public
v() : OOGmp
Return values
OOGmp —The 'v' value.
value()
Gets the value of the transaction.
public
value() : OOGmp
Return values
OOGmp —The value in Wei.
valueFmt()
Gets the value of the transaction and formats it with WeiFormatter, proxying params to it.
public
valueFmt(int $finalDecimals[, int|string|EtherFormats $format = EtherFormats::ETHER ]) : string
Parameters
- $finalDecimals : int
-
Number of decimals for formatting.
- $format : int|string|EtherFormats = EtherFormats::ETHER
-
Ether format.
Return values
string —Formatted value.
blanksFromRPCArr()
protected
blanksFromRPCArr(array<string|int, mixed> $rpcArr) : void
Parameters
- $rpcArr : array<string|int, mixed>
internalEncodeBin()
protected
internalEncodeBin(bool $signing, int|null $signingChainID) : string
Parameters
- $signing : bool
- $signingChainID : int|null
Tags
Return values
stringsetGasPriceOrBaseFee()
protected
setGasPriceOrBaseFee(OOGmp $fee) : static
Parameters
- $fee : OOGmp
Return values
staticsetInnerFromRLPValues()
protected
setInnerFromRLPValues(array<string|int, mixed> $rlpValues) : void
Parameters
- $rlpValues : array<string|int, mixed>