From 14ca7dd36ddebef4a2658bb8b9c6a9863ceddf2f Mon Sep 17 00:00:00 2001 From: Shubham Singhal Date: Tue, 30 Jul 2024 14:46:16 +0530 Subject: [PATCH] Implemented functionality to get coin balance --- CHANGELOG.md | 1 + src/index.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7d408e..04a659d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,5 +5,6 @@ - Implemented Keyring functionality to manage accounts - Implemented functions to add account, export accounts & import accounts - Implemented functionality to sign a message +- Implemented functionality to get coin balance for a wallet diff --git a/src/index.js b/src/index.js index d146061..c5f3d73 100644 --- a/src/index.js +++ b/src/index.js @@ -474,4 +474,9 @@ class KeyringController extends EventEmitter { } -module.exports = { KeyringController } \ No newline at end of file +const getBalance = async (address, web3) => { + const balance = await web3.eth.getBalance(address); + return { balance: web3.utils.fromWei(balance, 'ether') } +} + +module.exports = { KeyringController, getBalance } \ No newline at end of file