Skip to content

Commit

Permalink
adding effective gas price to transactionreceipt (#4694)
Browse files Browse the repository at this point in the history
* 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 <me@wyatt.email>
  • Loading branch information
luu-alex and spacesailor24 committed Jan 12, 2022
1 parent 9c9417a commit 0b890b7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,5 +497,6 @@ Released with 1.0.0-beta.37 code base.

### Fixed
- Fix a typo in the documentation for `methods.myMethod.send` (#4599)
- Added effectiveGasPrice to TransactionReceipt (#4692)
- Correction in documentation for `web3.eth.accounts.signTransaction` (#4576)
- Updated README to include Webpack 5 create-react-app support instructions (#4173)
3 changes: 2 additions & 1 deletion docs/web3-eth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``: 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
Expand Down
3 changes: 3 additions & 0 deletions packages/web3-core-helpers/src/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ 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);
}
Expand Down
1 change: 1 addition & 0 deletions packages/web3-core/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export interface TransactionReceipt {
contractAddress?: string;
cumulativeGasUsed: number;
gasUsed: number;
effectiveGasPrice: number;
logs: Log[];
logsBloom: string;
events?: {
Expand Down
2 changes: 2 additions & 0 deletions test/eth.getTransactionReceipt.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var txResult = {
"contractAddress":"0x407d73d8a49eeb85d32cf465507dd71d507100c1",
"cumulativeGasUsed":"0x7f110",
"gasUsed": "0x7f110",
"effectiveGasPrice": "0x09184e72a000",
"logs": [{
transactionIndex: '0x3e8',
logIndex: '0x3e8',
Expand All @@ -36,6 +37,7 @@ var formattedTxResult = {
"contractAddress":"0x407D73d8a49eeb85D32Cf465507dd71d507100c1", // checksum address
"cumulativeGasUsed": 520464,
"gasUsed": 520464,
"effectiveGasPrice": 10000000000000,
"logs": [{
id: "log_2b801386",
transactionIndex: 1000,
Expand Down

0 comments on commit 0b890b7

Please sign in to comment.