hi everybody…
I am trying to capture the balance of the user connecting to my DAPP with ethers.js
According to its documentation it is done like this:
// Get the balance of an account (by address or ENS name, if supported by network)
balance = await provider.getBalance("ethers.eth")
// { BigNumber: "2337132817842795605" }
I work in BSC testnet. I don’t know very well what the ENS refers to.
I copy the function of my App.js that tries to capture this data
async function requestAccount() {
const account = await window.ethereum.request({ method: 'eth_requestAccounts' });
const provider = new ethers.providers.Web3Provider(window.ethereum)
const balance = await provider.getBalance("ethers.eth");
document.querySelector('#wallet').innerHTML=account.toString();
document.querySelector('#balance').innerHTML=balance.toString();
}