I am trying to get the SOL balance from a phantom wallet. The wallet has > 0 SOL in it, so I know that something is wrong when I make the call. Here is my code:
(async () => {
const connection = new solanaWeb3.Connection(
solanaWeb3.clusterApiUrl('devnet'),
'confirmed',
);
if (phantom && phantom.publicKey !== null) {
const balance = await connection.getBalance(phantom.publicKey)
console.log(balance);
}
})();
What am I doing wrong?