3

I am getting the following error

Deploying contracts with the account: 0xC5EE6A5a3F78c05636cb3678500287A2c8AcAb12
Account balance: 523927171098673317
Error: insufficient funds for intrinsic transaction cost [ See: https://links.ethers.org/v5-errors-INSUFFICIENT_FUNDS ] (error={"name":"ProviderError","_stack":"ProviderError: insufficient funds for gas * price + value\n    at HttpProvider.request 

I am attempting to run the following script via hardhat

async function main() {
  const [deployer] = await ethers.getSigners();

  console.log("Deploying contracts with the account:", deployer.address);

  console.log("Account balance:", (await deployer.getBalance()).toString());

  const Token = await ethers.getContractFactory("HyperleagueToken");
  const token = await Token.deploy();

  console.log("Token address:", token.address);

  const Nft = await ether.getContractFactory("Hyperleague");
  const nft = await Nft.deploy();

  console.log("Nft address:", nft.address);

  const MarketPlace = await ethers.getContractFactory("MarketPlace");
  const marketPlace = await MarketPlace.deploy(token.address, nft.address);
  
  console.log("MarketPlace address:", marketPlace.address);
  
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

Here is hardhat.config file

require("@nomicfoundation/hardhat-toolbox");

const { mnemonic } = require('./secrets.json');

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async () => {
  const accounts = await ethers.getSigners();

  for (const account of accounts) {
    console.log(account.address);
  }
});

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more

/**
 * @type import('hardhat/config').HardhatUserConfig
 */
module.exports = {
  defaultNetwork: "mainnet",
  networks: {
    localhost: {
      url: "http://127.0.0.1:8545"
    },
    hardhat: {
    },
    testnet: {
      url: "https://data-seed-prebsc-1-s1.binance.org:8545",
      chainId: 97,
      gasPrice: 50000000000,
      accounts: {mnemonic: mnemonic}
    },
    mainnet: {
      url: "https://bsc-dataseed.binance.org/",
      chainId: 56,
      accounts: {mnemonic: mnemonic}
    }
  },
  solidity: {
  version: "0.8.9",
  settings: {
    optimizer: {
      enabled: true
    }
   }
  },
  paths: {
    sources: "./contracts",
    tests: "./test",
    cache: "./cache",
    artifacts: "./artifacts"
  },
  mocha: {
    timeout: 20000
  }
};

2
  • The account you are using does not have enough BNB to cover the gas fees for the transactions
    – Saxtheowl
    Apr 10, 2023 at 7:35
  • Account Balance is 0.5 BNB Apr 10, 2023 at 8:04

1 Answer 1

1

If you have 0.5 BNB be sure to check those things, the account you are using for the contract might not be the same, check again if it is the one in your secrets.json file, also your BNB balance could be on a different network check that it use the correct one in hardhat.config.js , be sure that you have exactly 0.5 BNB and not in another format like wei you can use this console.log("Account balance:", ethers.utils.formatUnits(await deployer.getBalance(), 18));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.