wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.19k stars 292 forks source link

Adding Gas Limit to transaction #548

Closed mgroovyank closed 4 months ago

mgroovyank commented 4 months ago

Describe the bug How can I add gas Limit to a transaction. I don't see any documentation regarding that.

Here is what my transaction looks like:

  transaction: {
    to: '0xB3A8526A1116EaA76288F31f39bBaC72239A78A4',
    from: '0xd383ccF184830d26C3F6a8656f84193934385CFb',
    data: ''
  },

here is my transaction script:

const { deployer } = await getNamedAccounts();
  const certificateSepolia = await ethers.getContract(
    "CertificateSepolia",
    deployer
  );
  const transactionResponse = await certificateSepolia.mint(
    receiverStudentAddress,
    ipfsTokenURI
  );
  await transactionResponse.wait(1);

I want to manually increase the gas limit.

versions "@nomicfoundation/hardhat-ethers": "^3.0.5", "hardhat": "^2.22.3", "hardhat-deploy": "^0.12.4", "hardhat-deploy-ethers": "^0.4.2"

Adding gas parameter to hardhat.config.js doesn;t work for me. Please help me, how can I set gas limit?


    sepolia: {
      url: SEPOLIA_RPC_URL,
      accounts: [SEPOLIA_PRIVATE_KEY],
      chainId: 11155111,
      blockConfirmations: 3,
      gas: 500000,
    },
mgroovyank commented 4 months ago

@wighawag I'm using execute function:

  const receipt = await execute(
    "CertificateSepolia",
    { from: deployer, gasLimit: 400000 },
    "mint",
    [receiverStudentAddress, ipfsTokenURI]
  );

But get below error:

Error: expected 2 arguments for method "mint", got 1

mgroovyank commented 4 months ago

I found the correct way by using execute function of deployments helper.