From 221dce3d73e27fca7d2cd11d8163a11f56cac98b Mon Sep 17 00:00:00 2001 From: Roman Storm Date: Tue, 16 Feb 2021 21:48:44 -0800 Subject: [PATCH] add MAX_GAS_PRICE --- src/Transaction.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Transaction.js b/src/Transaction.js index 3329c4f..0b53515 100644 --- a/src/Transaction.js +++ b/src/Transaction.js @@ -129,7 +129,9 @@ class Transaction { } } if (!this.tx.gasPrice) { - this.tx.gasPrice = await this._getGasPrice('fast') + const fastGasPrice = BigNumber.from(await this._getGasPrice('fast')) + const maxGasPrice = parseUnits(this.config.MAX_GAS_PRICE.toString(), 'gwei') + this.tx.gasPrice = min(fastGasPrice, maxGasPrice).toHexString() } if (!this.manager._nonce) { this.manager._nonce = await this._getLastNonce()