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

Transaction receipt has undefined gas price when gas price is 0 #4014

Closed
fvictorio opened this issue Apr 28, 2023 · 5 comments
Closed

Transaction receipt has undefined gas price when gas price is 0 #4014

fvictorio opened this issue Apr 28, 2023 · 5 comments
Assignees
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published. v6 Issues regarding v6

Comments

@fvictorio
Copy link

fvictorio commented Apr 28, 2023

Ethers Version

6.3.0

Search Terms

receipt gasprice undefined zero 0

Describe the Problem

The gas price in the receipt of a transaction with 0 gas price is undefined instead of 0n.

To reproduce, start a Hardhat node (npx hardhat node in any Hardhat project) and run node script.mjs in another terminal.

Code Snippet

import { ethers } from "ethers";

/*
contract Foo {
  uint public x = 1;

  function inc() public {
    x++;
  }
}
*/
const bytecode =
  "0x6080604052600160005534801561001557600080fd5b50610163806100256000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80630c55699c1461003b578063371303c014610059575b600080fd5b610043610063565b604051610050919061009b565b60405180910390f35b610061610069565b005b60005481565b60008081548092919061007b906100e5565b9190505550565b6000819050919050565b61009581610082565b82525050565b60006020820190506100b0600083018461008c565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006100f082610082565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610122576101216100b6565b5b60018201905091905056fea2646970667358221220ce715c269a6493f974b0599f932508687267018b4e3881d45acf952eac8aa45364736f6c63430008110033";
const abi = ["function inc() public"];

const provider = new ethers.JsonRpcProvider("http://localhost:8545");
const signer = new ethers.NonceManager(
  new ethers.Wallet("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", provider)
);

const Foo = new ethers.ContractFactory(abi, bytecode, signer);
const foo = await Foo.deploy();
await provider.send("hardhat_setNextBlockBaseFeePerGas", ["0x0"]);

const tx = await foo.inc({ gasPrice: 0 });

const receipt = await tx.wait();

console.log(receipt.gasPrice);

Contract ABI

No response

Errors

No response

Environment

Hardhat

Environment (Other)

No response

@fvictorio fvictorio added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Apr 28, 2023
@fvictorio
Copy link
Author

I think changing this || for a ?? fixes the issue:

gasPrice: ((tx.effectiveGasPrice || tx.gasPrice) as bigint),

@samuelmonday699
Copy link

samuelmonday699 commented Apr 28, 2023 via email

@ricmoo
Copy link
Member

ricmoo commented Apr 28, 2023

This seems like it is definitely a bug. Heading to a coffee shop now and will get looking at it.

The env CI is pretty much working now. I just had a few more things to test out and so I can start pumping out releases again, with better build-setup regressions.

@ricmoo ricmoo added the on-deck This Enhancement or Bug is currently being worked on. label Apr 28, 2023
@ricmoo
Copy link
Member

ricmoo commented Apr 28, 2023

This seems like it is definitely a bug. Heading to a coffee shop now and will get looking at it.

The env CI is pretty much working now. I just had a few more things to test out and so I can start pumping out releases again, with better build-setup regressions.

@ricmoo
Copy link
Member

ricmoo commented May 20, 2023

Fixed in v6.4.0.

Let me know if there are any more problems.

Thanks! :)

@ricmoo ricmoo closed this as completed May 20, 2023
@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. enhancement New feature or improvement. and removed on-deck This Enhancement or Bug is currently being worked on. investigate Under investigation and may be a bug. labels May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

3 participants