Skip to content

Instantly share code, notes, and snippets.

@gasolin
Created April 10, 2018 08:47
Show Gist options
  • Select an option

  • Save gasolin/d2626c552e0cd02f04bd38aee978d0b4 to your computer and use it in GitHub Desktop.

Select an option

Save gasolin/d2626c552e0cd02f04bd38aee978d0b4 to your computer and use it in GitHub Desktop.

Revisions

  1. gasolin created this gist Apr 10, 2018.
    21 changes: 21 additions & 0 deletions waitForTxToBeMined.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    // https://medium.com/metamask/calling-a-smart-contract-with-a-button-d278b1e76705
    async function waitForTxToBeMined (txHash) {

    let txReceipt
    while (!txReceipt) {

    try {

    txReceipt = await eth.getTransactionReceipt(txHash)

    } catch (err) {

    return indicateFailure(err)

    }

    }

    indicateSuccess()

    }