diff --git a/package.json b/package.json index 08fd511..b0c49cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tx-manager", - "version": "0.2.4", + "version": "0.2.5", "description": "", "main": "index.js", "scripts": { diff --git a/src/Transaction.js b/src/Transaction.js index 8b2ddb6..3779ed9 100644 --- a/src/Transaction.js +++ b/src/Transaction.js @@ -175,6 +175,9 @@ class Transaction { this.currentTxHash = null continue } + if (Number(receipt.status) === 0) { + throw new Error('Transaction failed') + } const currentBlock = await this._provider.getBlockNumber() const confirmations = Math.max(0, currentBlock - receipt.blockNumber) @@ -234,7 +237,10 @@ class Transaction { } } - console.log('Mined. Start waiting for confirmations...') + if (Number(receipt.status) === 0) { + throw new Error('Transaction failed') + } + this._emitter.emit('mined', receipt) this.currentTxHash = receipt.transactionHash }