Skip to content

Instantly share code, notes, and snippets.

@BesrourMS
Created December 25, 2021 15:10
Show Gist options
  • Save BesrourMS/5343bc672c2426106b5814567718ca7d to your computer and use it in GitHub Desktop.
Save BesrourMS/5343bc672c2426106b5814567718ca7d to your computer and use it in GitHub Desktop.
Get Solana Balance Web3.js
let wallet = "2aNh8y5HgMtsyEkCHwTd8wCtVQkLzuDf9PPhJqqddzKo"
Promise.resolve(new solanaWeb3.Connection(solanaWeb3.clusterApiUrl('mainnet-beta'),'confirmed')).then((resp) =>{
resp.getAccountInfo(new solanaWeb3.PublicKey(wallet)).then((resp) =>{
console.log(resp.lamports/solanaWeb3.LAMPORTS_PER_SOL)
})
});
<script src="https://unpkg.com/@solana/web3.js@latest/lib/index.iife.min.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment