Skip to content

Commit

Permalink
Implemented functionality to get gass fees
Browse files Browse the repository at this point in the history
  • Loading branch information
Husienvora committed Aug 16, 2024
1 parent 3ae5f2b commit 8af86b7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 19 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 8af86b7

Please sign in to comment.