Skip to content

Instantly share code, notes, and snippets.

@italosantana
Created July 1, 2022 12:26
Show Gist options
  • Save italosantana/8d17ba521baa69872eabfbe3e78729c8 to your computer and use it in GitHub Desktop.
Save italosantana/8d17ba521baa69872eabfbe3e78729c8 to your computer and use it in GitHub Desktop.
function WalletBalance() {
const [balance, setBalance] = useState();
const getBalance = async () => {
const [account] = await window.ethereum.request({ method: 'eth_requestAccounts' });
const provider = new ethers.providers.Web3Provider(window.ethereum);
const balance = await provider.getBalance(account);
setBalance(ethers.utils.formatEther(balance));
}
.....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment