[Ethereum] ERROR Transaction was not mined within 50 blocks, please make sure your transaction was properly send

go-ethereumweb3js

I am getting the following error While trying to transfer fund from one account to another:

Unhandled rejection Error: Transaction was not mined within 50 blocks, please make sure your transaction was properly send. Be aware that it might still be mined!
    at /home/munim/codes/eth-test-01/node_modules/web3/packages/web3-core-method/src/index.js:368:45
    at bound (domain.js:301:14)
    at runBound (domain.js:314:12)
    at tryCatcher (/home/munim/codes/eth-test-01/node_modules/web3/packages/web3-core-promievent/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/munim/codes/eth-test-01/node_modules/web3/packages/web3-core-promievent/node_modules/bluebird/js/release/promise.js:497:31)
    at Promise._settlePromise (/home/munim/codes/eth-test-01/node_modules/web3/packages/web3-core-promievent/node_modules/bluebird/js/release/promise.js:555:18)
    at Promise._settlePromise0 (/home/munim/codes/eth-test-01/node_modules/web3/packages/web3-core-promievent/node_modules/bluebird/js/release/promise.js:600:10)
    at Promise._settlePromises (/home/munim/codes/eth-test-01/node_modules/web3/packages/web3-core-promievent/node_modules/bluebird/js/release/promise.js:679:18)
    at Async._drainQueue (/home/munim/codes/eth-test-01/node_modules/web3/packages/web3-core-promievent/node_modules/bluebird/js/release/async.js:125:16)
    at Async._drainQueues (/home/munim/codes/eth-test-01/node_modules/web3/packages/web3-core-promievent/node_modules/bluebird/js/release/async.js:135:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/munim/codes/eth-test-01/node_modules/web3/packages/web3-core-promievent/node_modules/bluebird/js/release/async.js:16:14)
    at runCallback (timers.js:781:20)
    at tryOnImmediate (timers.js:743:5)
    at processImmediate [as _immediateCallback] (timers.js:714:5)

My genesis.json file:

{
  "config": {
        "chainId": 10,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
  "alloc"      : {},
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x20000",
  "extraData"  : "",
  "gasLimit"   : "0x2fefd8",
  "nonce"      : "0x0000000000000042",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}

Initiated geth with the following command:

~ geth --datadir="./prinet-betty/data/" init prinet-betty/genesis.json
~ eth --fast --cache=1024 --rpc --rpcaddr="localhost" --rpccorsdomain="*" --datadir="./prinet-betty/data" --nodiscover --rpcapi="db,eth,net,web3,personal" console

The following code returns the error

const Web3 = require("web3");

let web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

web3.eth.getAccounts((err, acc) => {
    console.log(acc);
    web3.eth.personal.unlockAccount(acc[0], "qwer1234", 1500)
    .then(res => {
        if (res === true) {
            web3.eth.sendTransaction({
                from: acc[0],
                to: acc[1],
                value: web3.utils.toWei(0.1, "ether")
            })
            .then(console.log)
        }
    });
});

Best Answer

Before running this process, you will start before 5 min because it will increase the speed of mining process. To start mining run:-

miner.start() before compiling node js where api are created.