web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
        .once('transactionHash', function(hash){console.log(['transferToReceiver Trx Hash:' + hash]);})
        .once('receipt', function(receipt){console.log(['transferToReceiver Receipt:', receipt]);})
        .on('confirmation', (confirmationNumber) => {console.log('transferToReceiver confirmation: ' + confirmationNumber);})
        .on('error', console.error)
        .then(function (receipt){
            var trxJSON = {
                _seq: rlTrxSeq,
                _aft_bal: (10000000 - tokenAmount),
                _amt: tokenAmount,
                _st_sent_to: receiverPublicAddr,
                _tx_hash: receipt.transactionHash,
                _st_sent_tx_hash: receipt.transactionHash
            if (receipt.status === true){
                var sql = "CALL eth.sp_operation_staging_wallet('', '"
                                    + stagingPublicAddr + "', '"
                                    + stagingKeystoreAddr + "', '"
                                    + JSON.stringify(trxJSON) + "', '"
                                    + mode + "', '"
                                    + network + "')";


Here is my code. When the status is true, then I run some DB updates. The transaction is successful as well as the SP call. But the after the confirmation console.log stops at 24, it doesn't jump out. It looks like getting into a loop. How can I get out after finish?

enter image description here

  • What is the issue? The web3 v1 documentation says it will stop confirmations after twelve. But your code should continue executing correctly otherwise. – Ismael Jun 3 '18 at 5:34
  • @Ismael, So do you mean it is correct that it stops here? Since I run from command line, like $ node app.js, I think it should return to command line cursor. – TFT2012 Jun 3 '18 at 17:40
  • Node will not return to the command line if there's any task waiting. For example if you have a pending web request. Without the whole code it hard to say what it is waiting for. Sometimes it is the database because you have to explicitely disconnect after making changes and before exiting your program. – Ismael Jun 3 '18 at 18:00

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.