Created
July 1, 2022 12:26
-
-
Save italosantana/8d17ba521baa69872eabfbe3e78729c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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