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

Out of gas error using default args when deploying a contract setting tx.gasPrice to a state variable in the constructor #5855

Open
0xSamWitch opened this issue Oct 25, 2024 · 0 comments
Assignees

Comments

@0xSamWitch
Copy link

0xSamWitch commented Oct 25, 2024

Version of Hardhat

2.22.15

What happened?

Cannot deploy a specific contract to a blockchain (tried fantom, sonic testnet and arbitrum). It stores the tx.gasPrice in the constructor.

Transaction failing to deploy it with default args:

  const contract = await ethers.deployContract("Contract");
  await contract.waitForDeployment();

https://arbiscan.io/tx/0x4aba3be69ebbff1c9696fd7f71f62334249ad72a21e150973917bd425cdabf98

Transaction successful specifying a higher gas price:

  const contract = await ethers.deployContract("Contract", {gasLimit: 200000});
  await contract.waitForDeployment();

https://arbiscan.io/tx/0x3b97e44c329f71a7ba502162578e7761d20b2cb1ab64475f41d066a9f7a2e1d1

Minimal reproduction steps

Create this contract:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

contract Contract {
  uint64 private price; // Making it immutable works

  constructor() {
    price = uint64(tx.gasprice);
  }
}

Try to deploy it on a network other than hardhat:

  const contract = await ethers.deployContract("Contract");
  await contract.waitForDeployment();

A repo which can replicate this has been set up:
https://github.com/0xSamWitch/VRFRequestInfoDeploymentFailure

Search terms

out of gas, tx.gasPrice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

3 participants
@ChristopherDedominici @0xSamWitch and others