Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 0b890b7

Browse files
Alexspacesailor24
Alex
andauthored
adding effective gas price to transactionreceipt (#4694)
* adding effective gas price to transactionreceipt * editing changelog * updated gettransactionreceipt doc * adding gettransactionreceipt testcase with effectivegasprice * update doc * removing line Co-authored-by: Wyatt Barnes <[email protected]>
1 parent 9c9417a commit 0b890b7

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,5 +497,6 @@ Released with 1.0.0-beta.37 code base.
497497

498498
### Fixed
499499
- Fix a typo in the documentation for `methods.myMethod.send` (#4599)
500+
- Added effectiveGasPrice to TransactionReceipt (#4692)
500501
- Correction in documentation for `web3.eth.accounts.signTransaction` (#4576)
501502
- Updated README to include Webpack 5 create-react-app support instructions (#4173)

docs/web3-eth.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1402,8 +1402,9 @@ Returns
14021402
- ``to`` - ``String``: Address of the receiver. ``null`` when it's a contract creation transaction.
14031403
- ``contractAddress`` - ``String``: The contract address created, if the transaction was a contract creation, otherwise ``null``.
14041404
- ``cumulativeGasUsed`` - ``Number``: The total amount of gas used when this transaction was executed in the block.
1405-
- ``gasUsed``- ``Number``: The amount of gas used by this specific transaction alone.
1405+
- ``gasUsed`` - ``Number``: The amount of gas used by this specific transaction alone.
14061406
- ``logs`` - ``Array``: Array of log objects, which this transaction generated.
1407+
- ``effectiveGasPrice`` - ``Number``: The actual value per gas deducted from the senders account. Before EIP-1559, this is equal to the transaction's gas price. After, it is equal to baseFeePerGas + min(maxFeePerGas - baseFeePerGas, maxPriorityFeePerGas).
14071408

14081409
-------
14091410
Example

packages/web3-core-helpers/src/formatters.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ var outputTransactionReceiptFormatter = function (receipt) {
288288
receipt.logs = receipt.logs.map(outputLogFormatter);
289289
}
290290

291+
if (receipt.effectiveGasPrice) {
292+
receipt.effectiveGasPrice = utils.hexToNumber(receipt.effectiveGasPrice)
293+
}
291294
if (receipt.contractAddress) {
292295
receipt.contractAddress = utils.toChecksumAddress(receipt.contractAddress);
293296
}

packages/web3-core/types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ export interface TransactionReceipt {
213213
contractAddress?: string;
214214
cumulativeGasUsed: number;
215215
gasUsed: number;
216+
effectiveGasPrice: number;
216217
logs: Log[];
217218
logsBloom: string;
218219
events?: {

test/eth.getTransactionReceipt.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var txResult = {
1010
"contractAddress":"0x407d73d8a49eeb85d32cf465507dd71d507100c1",
1111
"cumulativeGasUsed":"0x7f110",
1212
"gasUsed": "0x7f110",
13+
"effectiveGasPrice": "0x09184e72a000",
1314
"logs": [{
1415
transactionIndex: '0x3e8',
1516
logIndex: '0x3e8',
@@ -36,6 +37,7 @@ var formattedTxResult = {
3637
"contractAddress":"0x407D73d8a49eeb85D32Cf465507dd71d507100c1", // checksum address
3738
"cumulativeGasUsed": 520464,
3839
"gasUsed": 520464,
40+
"effectiveGasPrice": 10000000000000,
3941
"logs": [{
4042
id: "log_2b801386",
4143
transactionIndex: 1000,

0 commit comments

Comments
 (0)