我正在尝试从虚拟钱包中获取 SOL 余额。钱包里有 > 0 SOL,所以当我打电话时,我知道有问题。这是我的代码:
(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);
}
})();
我究竟做错了什么?