I send a transaction with web3 1.0.0 from a script like:

async function sending(deployed_contract) {
    await deployed_contract.methods.mymethod(1).send({from: account})
                    .on('transactionHash', function(hash){
                    .on('receipt', function(receipt){
                    .on('confirmation', function(confirmationNumber, receipt){
                    .on('error', console.error);


and after receiving the confirmations and the receipt, the program continues executing and never ends. Could anyone explain to me why it happens?

UPDATED: Could it be because I have my own wallet running? or should the program execution be finished anyway?

var create_wallet = function (){
    privateKey = 'xxx';
    return new ethers.Wallet(privateKey, web3.currentProvider); 

wallet = create_wallet()
  • 1
    How deployed_contract was created? It seems like a node issue, if you have a pending task it will not stopand will continue waiting for all task to finish. Some libraries will create a background task for example databases.
    – Ismael
    Commented Nov 13, 2018 at 21:27
  • Im doing: await contract.deploy({ data: '0x' }).send({...}) .then(function(newContractInstance){ deployed_contract = newContractInstance; }); and, as you say, it never ends. How could I finish this task? Commented Nov 13, 2018 at 22:05
  • 1
    Are you subscribing to events? Seriously, without examining the full source code it is impossible to tell which is causing your script to not finish. You can start with an empty javascript file and start adding back functionality until you find the resposible.
    – Ismael
    Commented Nov 13, 2018 at 22:15
  • I am not subscribed to events. I have added an updated in the description. Commented Nov 14, 2018 at 20:57
  • It is not possible to find the culprit without testing and examining the source code. Try starting with and empty file and start adding functionality until the error appear.
    – Ismael
    Commented Nov 15, 2018 at 18:27

1 Answer 1


Try commenting the code for confirmations, maybe nodes on the network keeps on confirming the transaction and that is the reason it keeps on executing.

Other thing is you haven't returned anything anywhere so there is no way for the code to break.

  • I tried doing that, but the problem is still happening Commented Nov 14, 2018 at 20:41
  • After .on('error'), try adding .then() and return the value inside it. OR You can return receipt after you've received one.
    – itsHarshad
    Commented Nov 15, 2018 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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