Irys-xyz / arweave-js-sdk

JS SDK for Irys on Arweave
110 stars 95 forks source link

Incorrect Solana Wallet Balance #43

Closed jasgreen closed 2 years ago

jasgreen commented 2 years ago

Hi

I have a really strange issue whereby the getLoadedBalance method returns a completely wrong amount compared to what I actually have in my wallet and what is shown in the error message when attempting to fund the transfer.

I've checked the providerUrl and wallet address values are the same so not sure what else it could be.

$ solana balance
0.006704023 SOL
const bundlr = new Bundlr(
          'https://devnet.bundlr.network',
          'solana',
          key,
          {
            timeout: 60000,
            providerUrl: 'https://api.devnet.solana.com',
          },
        );

const balance = await bundlr.getLoadedBalance();
console.log(balance.toNumber() / LAMPORTS);
// returns 4.477788768

const tx = bundlr.createTransaction(data, opts)
const size = tx.size
const cost = await bundlr.getPrice(size);
console.log(cost.toNumber() / LAMPORTS);
// returns 0.00000136

await bundlr.fund(cost.minus(balance));
// returns {"error":{"logs":["Program 11111111111111111111111111111111 invoke [1]","Transfer: insufficient lamports 6699023, need 4477787408","Program 11111111111111111111111111111111 failed: custom program error: 0x1"]}
JesseTheRobot commented 2 years ago

Hey there @jasgreen , are you still getting this issue with the latest client?