From 8795d27a9422b280ad577494c5205c6ce47f8510 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 11 Jan 2022 19:04:21 -0500 Subject: [PATCH 1/6] adding effective gas price to transactionreceipt --- packages/web3-core-helpers/src/formatters.js | 4 ++++ packages/web3-core/types/index.d.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/packages/web3-core-helpers/src/formatters.js b/packages/web3-core-helpers/src/formatters.js index 94b29cfa432..6cdfbd8f065 100644 --- a/packages/web3-core-helpers/src/formatters.js +++ b/packages/web3-core-helpers/src/formatters.js @@ -288,6 +288,10 @@ var outputTransactionReceiptFormatter = function (receipt) { receipt.logs = receipt.logs.map(outputLogFormatter); } + if (receipt.effectiveGasPrice) { + receipt.effectiveGasPrice = utils.hexToNumber(receipt.effectiveGasPrice) + } + if (receipt.contractAddress) { receipt.contractAddress = utils.toChecksumAddress(receipt.contractAddress); } diff --git a/packages/web3-core/types/index.d.ts b/packages/web3-core/types/index.d.ts index 4065992bc7b..3015bf288a3 100644 --- a/packages/web3-core/types/index.d.ts +++ b/packages/web3-core/types/index.d.ts @@ -213,6 +213,7 @@ export interface TransactionReceipt { contractAddress?: string; cumulativeGasUsed: number; gasUsed: number; + effectiveGasPrice: number; logs: Log[]; logsBloom: string; events?: { From 522006ce2b73c2c65660ed148dfbdc6a5693b9c0 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 11 Jan 2022 19:17:32 -0500 Subject: [PATCH 2/6] editing changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 182437c18f0..57d7fba42ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -496,4 +496,5 @@ Released with 1.0.0-beta.37 code base. ## [1.7.1] ### Fixed -- Fix a typo in the documentation for `methods.myMethod.send` (#4599) \ No newline at end of file +- Fix a typo in the documentation for `methods.myMethod.send` (#4599) +- Added effectiveGasPrice to TransactionReceipt (#4692) \ No newline at end of file From 789e4008ac74c9996adfcc68f62ca61f11efada4 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 11 Jan 2022 20:07:50 -0500 Subject: [PATCH 3/6] updated gettransactionreceipt doc --- docs/web3-eth.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/web3-eth.rst b/docs/web3-eth.rst index 3194ef7287d..0fa72deb59e 100644 --- a/docs/web3-eth.rst +++ b/docs/web3-eth.rst @@ -1402,8 +1402,9 @@ Returns - ``to`` - ``String``: Address of the receiver. ``null`` when it's a contract creation transaction. - ``contractAddress`` - ``String``: The contract address created, if the transaction was a contract creation, otherwise ``null``. - ``cumulativeGasUsed`` - ``Number``: The total amount of gas used when this transaction was executed in the block. - - ``gasUsed``- ``Number``: The amount of gas used by this specific transaction alone. + - ``gasUsed`` - ``Number``: The amount of gas used by this specific transaction alone. - ``logs`` - ``Array``: Array of log objects, which this transaction generated. + - ``effectiveGasPrice`` - ``Number``: it is equal to the actual gas price paid for inclusion. This calculation differs depending if the transaction is an EIP-1559 transaction or not. ------- Example From bb68ed0b898f5ffe5ef9e36c79422a0eec088932 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 11 Jan 2022 20:28:11 -0500 Subject: [PATCH 4/6] adding gettransactionreceipt testcase with effectivegasprice --- test/eth.getTransactionReceipt.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/eth.getTransactionReceipt.js b/test/eth.getTransactionReceipt.js index dabb7f6bb64..ee86e5bf85d 100644 --- a/test/eth.getTransactionReceipt.js +++ b/test/eth.getTransactionReceipt.js @@ -10,6 +10,7 @@ var txResult = { "contractAddress":"0x407d73d8a49eeb85d32cf465507dd71d507100c1", "cumulativeGasUsed":"0x7f110", "gasUsed": "0x7f110", + "effectiveGasPrice": "0x09184e72a000", "logs": [{ transactionIndex: '0x3e8', logIndex: '0x3e8', @@ -36,6 +37,7 @@ var formattedTxResult = { "contractAddress":"0x407D73d8a49eeb85D32Cf465507dd71d507100c1", // checksum address "cumulativeGasUsed": 520464, "gasUsed": 520464, + "effectiveGasPrice": 10000000000000, "logs": [{ id: "log_2b801386", transactionIndex: 1000, From 2fd44758fde0c98f279c254aec82e424cda24082 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 11 Jan 2022 20:32:49 -0500 Subject: [PATCH 5/6] update doc --- docs/web3-eth.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/web3-eth.rst b/docs/web3-eth.rst index 0fa72deb59e..e5ff527189a 100644 --- a/docs/web3-eth.rst +++ b/docs/web3-eth.rst @@ -1404,7 +1404,7 @@ Returns - ``cumulativeGasUsed`` - ``Number``: The total amount of gas used when this transaction was executed in the block. - ``gasUsed`` - ``Number``: The amount of gas used by this specific transaction alone. - ``logs`` - ``Array``: Array of log objects, which this transaction generated. - - ``effectiveGasPrice`` - ``Number``: it is equal to the actual gas price paid for inclusion. This calculation differs depending if the transaction is an EIP-1559 transaction or not. + - ``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). ------- Example From a7d10a967ef263eef3226cba673e0c7def26881e Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 12 Jan 2022 10:31:10 -0500 Subject: [PATCH 6/6] removing line --- packages/web3-core-helpers/src/formatters.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/web3-core-helpers/src/formatters.js b/packages/web3-core-helpers/src/formatters.js index 6cdfbd8f065..cef20a7090b 100644 --- a/packages/web3-core-helpers/src/formatters.js +++ b/packages/web3-core-helpers/src/formatters.js @@ -291,7 +291,6 @@ var outputTransactionReceiptFormatter = function (receipt) { if (receipt.effectiveGasPrice) { receipt.effectiveGasPrice = utils.hexToNumber(receipt.effectiveGasPrice) } - if (receipt.contractAddress) { receipt.contractAddress = utils.toChecksumAddress(receipt.contractAddress); }