diff --git a/CHANGELOG.md b/CHANGELOG.md index 76c2b45..7f4851d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,3 +6,4 @@ - Implemented functionality to sign a raw transaction - Implemented functionality to sign a message - Implemented functionality to get coin balance for a wallet +- Implemented functionality to get gass fees diff --git a/src/index.js b/src/index.js index c320ce2..b781663 100644 --- a/src/index.js +++ b/src/index.js @@ -510,6 +510,25 @@ class KeyringController extends EventEmitter { const receipt = await web3.eth.sendSignedTransaction(signedTx); return { transactionDetails: receipt.transactionHash }; } + + async getFees(bevmTx, web3) { + const { from, to, value, data } = bevmTx; + const gasLimit = await web3.eth.estimateGas({ to, from, value, data }); + const gasPrice = parseInt(await web3.eth.getGasPrice()); + const fees = { + slow: { + gasPrice: gasPrice, + }, + standard: { + gasPrice: gasPrice + parseInt(gasPrice * 0.05), + }, + fast: { + gasPrice: gasPrice + parseInt(gasPrice * 0.1), + }, + baseFee: 0, + }; + return { gasLimit: gasLimit, fees: fees }; + } } const getBalance = async (address, web3) => {