I have started a geth client using the below client(I had already created two accounts.:

geth --datadir datadir --networkid 123 --rpc --rpcaddr="localhost" --rpccorsdomain="*" --unlock <my account> --minerthreads="1" --maxpeers=0 --mine console

I opened the the ethereum wallet and deployed the smart contract from there. The transactionId and the contract address is received on my geth console.

Then I started my Dapp and created the instances of the contract and I am calling the contract invoking a contract function through web3 API. The contract function gets invoked but the transaction does not get submitted in the block unless I start mining. Hence I started miner.start() This started mining numerous blocks.

My question is where are these blocks coming from if I have my own private net and have submitted only one transaction. This is adding too many blocks and my blocksize is increasing unnecessarily. How to mine only the transaction I have submitted?


1 Answer 1


These blocks are mined by your client by using miner.start() the blocks are mined until your transaction got included in one of these blocks. To stop the operation tape miner.stop() even the log didn't give you the prompt. However, the best thing is using a script that mine only the pending transactions (you mine only few blocks until your transaction got mined).

such script will contain

var mining_threads = 1

    function checkWork() {
        if (eth.getBlock("pending").transactions.length > 0) {
            if (eth.mining) return;
            console.log("== Pending transactions! Mining...");
        } else {
            console.log("== No transactions! Mining stopped.");
    console.log("checkWork() is defined");
    eth.filter("latest", function(err, block) { checkWork(); });
    eth.filter("pending", function(err, block) { checkWork(); });


on geth use

  • Do I have to loadscript() for each transaction?
    – Lakshmi
    Nov 24, 2016 at 15:35
  • I tried this; now the mining is taking too long time; I am not sure why it is so; I have develeoped a Dapp based on cryptocurrency ethereum example. when i am transferring the token to another account it is taking too long a time to get mined now. :( . Is this because the block size has increased? Currently the block size is 97.
    – Lakshmi
    Nov 24, 2016 at 16:33
  • this doesn't have any relation with the block size, you need only to wait few seconds until your transaction got mined, you could instead using previous script use : miner.start(8); admin.sleepBlocks(10); miner.stop() ; you precise how many block to mine
    – Badr Bellaj
    Nov 24, 2016 at 17:02

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