Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding effective gas price to transactionreceipt #4694

Merged
merged 8 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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