I am trying to deploy smart contract on private network and do transactions via nodejs script. This is my genesis block:

    "config": {
        "chainId": 16,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    "alloc": {},
    "difficulty" : "200",
    "gasLimit" : "99999999999999"

I have used following command to start the network:

geth --datadir ./exp4 --networkid 16 --rpc --rpcapi "eth,net,web3,personal,miner" --nodiscover --allow-insecure-unlock --port 3000 console

I am deploying it using truffle. This is my smart contract:

pragma solidity ^0.5.8;
contract Hello {
   string public message;
   function HelloWorld() public{
       message = "Hello, World : This is a Solidity Smart Contract on the Private Ethereum Blockchain ";

Migration file:

var Hello = artifacts.require("./Hello.sol");
module.exports = function(deployer) {

Truffle config:

rpc: {
networks: {
    development: {
        host: "",     // Localhost (default: none)
        port: 8545,            // Standard Ethereum port (default: none)
        network_id: "16",      // Any network (default: none)
        from: "0xc3ec8cfb877b639094d2bc4bb99651dcb0c36aff",
        gas: 20000000

Finally, I am running this script which gives the error as mentioned in title of gas limit exceeding

var Web3 = require('web3')
var web3_http = new Web3(new Web3.providers.HttpProvider(''));
const fs = require('fs');
const con = JSON.parse(fs.readFileSync('./build/contracts/Hello.json', 'utf8'));
var abi = con.abi;
var cont = new web3_http.eth.Contract(abi, "0xdCf9a6832Fae44B081f62513D04c2E30fB9a6A00");

cont.methods.HelloWorld().estimateGas({from: "0xc3ec8cfb877b639094d2bc4bb99651dcb0c36aff"})

0xc3ec8cfb877b639094d2bc4bb99651dcb0c36aff is the account address and 0xdCf9a6832Fae44B081f62513D04c2E30fB9a6A00 is the address at which my contract is deployed. It shows correct ether value for my account and fetches the contract correctly but gives a gas limit exceeding error when estimating gas. I was initially trying to deploy a personal contract which was much more complex and it gave the same error. So, I tried deploying a simple contract but it still shows the same error. Link to my previous question:

It would be really helpful if anyone could tell what it is that I doing wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.