Created
December 6, 2022 18:36
-
-
Save JhonatanHern/648766f4fcd27f3fc2b102bf7991eb9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sleep = (milliseconds) => { return new Promise(resolve => setTimeout(resolve, milliseconds)) } | |
const waitUntilTransactionIsConfirmed = hash => new Promise(async (succ, err) => { | |
while(true) { | |
const transaction = await web3.eth.getTransactionReceipt(hash) | |
if (transaction) { | |
console.log('transaction status: ', transaction); | |
return (transaction.status ? succ : err)(transaction) | |
} | |
await sleep(1000) // 1 second | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment