Web3BB

    • Register
    • Login
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Hardhat Ganache-cli ProviderError: HttpProviderError http.ts:78:19

    Ethers
    1
    1
    2866
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      web3master last edited by web3master

      I am using ganache-cli with mainnet fork, but I use Hardhat with Ethers library to deploy the contract.

      Here is an example:

      Contract Code (HelloWorld.sol):

      // SPDX-License-Identifier: MIT
      pragma solidity <=0.8.10;
      
      contract HelloWorld {
      
          string saySomething;
      
          constructor() {
              saySomething = "Hello World!";
          }
      
          function speak() public view returns(string memory) {
              return saySomething;
          }
      }
      

      Deployment Code:

      const { ethers } = require("hardhat");
      const config = require("../config.json")
      const fs = require('fs');
      
      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 HelloWorld = await ethers.getContractFactory("HelloWorld");
      	const contract = await HelloWorld.deploy();
      
      	console.log("Contract deployed at:", contract.address);
      }
      
      main()
        .then(() => process.exit(0))
        .catch(error => {
      	console.error(error);
      	process.exit(1);
        });
      

      Deployment Output:

      npx hardhat --network ganache  run scripts/deployHelloWorld.js
      
      Deploying contracts with the account: 0x3244e66158295043AF04548925EbaE25cCC73c8F
      Account balance: 1000000000000000000000
      ProviderError: HttpProviderError
          at HttpProvider.request (/Users/dapp/node_modules/hardhat/src/internal/core/providers/http.ts:78:19)
          at LocalAccountsProvider.request (/Users/dapp/node_modules/hardhat/src/internal/core/providers/accounts.ts:181:36)
          at processTicksAndRejections (node:internal/process/task_queues:96:5)
          at EthersProviderWrapper.send (/Users/dapp/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)
      

      adding:

        try {
          const contract = await HelloWorld.deploy();
        } catch (e) {
            console.log(e.message);
            throw e;
        }
      

      It gives more info:

      npx hardhat --network ganache  run scripts/deployHelloWorld.js
      Deploying contracts with the account: 0x3244e66158295043AF04548925EbaE25cCC73c8F
      Account balance: 1000000000000000000000
      VM Exception while processing transaction: Transaction's maxFeePerGas (2000000000) is less than the block's baseFeePerGas (7978231074) (vm hf=london -> block -> tx)
      

      Solution

      add gasPrice: 50000000000
      to hardhat.config.js

        networks: {
          ganache: {
            gasPrice: 50000000000,
            url: "http://127.0.0.1:7545",
            accounts: [privateKey]
          }
        }
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post