From 14c9f5bb89ee9788f00c9a34b8583319af0d638d Mon Sep 17 00:00:00 2001 From: Emre Kanatli Date: Fri, 19 Nov 2021 17:45:27 -0500 Subject: [PATCH] Estimate Gas (#30) * estimate gas (#29) --- src/Wallet/Wallet.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Wallet/Wallet.ts b/src/Wallet/Wallet.ts index ebcaebe2..631f2144 100644 --- a/src/Wallet/Wallet.ts +++ b/src/Wallet/Wallet.ts @@ -298,6 +298,22 @@ export abstract class WalletProvider { return await estimateErc20Gas(contractAddress, from, to, amount); } + /** + * Estimate gas limit for the given inputs. + * @param to + * @param data + */ + async estimateGas(to: string, data: string) { + const from = this.getAddressC(); + const nonce = await web3.eth.getTransactionCount(from); + return await web3.eth.estimateGas({ + from: from, + nonce: nonce, + to: to, + data: data, + }); + } + /** * Estimate the gas needed for a AVAX send transaction on the C chain. * @param to Destination address.