3

For some addresses, if you call getSignaturesForAddress to get its entire transaction history and sum up all of the balance changes (via calculating postBalances[i] - preBalances[i]) you almost always end up with a number that's slightly larger (about 0.0006 SOL or more) than if you simply call getBalance from an RPC node.

Does anyone know why this discrepancy might exist? Rent? Hidden fees?

1
  • Could it also be that there's a lot of txs going on for these accounts and it's just timing out?
    – Ake
    Commented Dec 28, 2023 at 1:34

2 Answers 2

1

It's likely ignoring the rent-exempt amount when computing getBalance. However the rent exemption is about 0.00089088, so I'm not sure why you would get 0.0006

0

Things you might be doing wrong.

You need to add the difference to a balance that you initialize at 0

let balance = 0
loop transactions {
   balance += postBalances[i] - preBalances[i]
}

And make sure the i you choosing is the wallet you're trying to extract the balance each time. Order of the accounts changes

And finally, make sure you extract all the Transactions. for getSignaturesForAddress

the limit: <number> - maximum transaction signatures to return (between 1 and 1,000, default: 1,000).

So you need to do 2 requests if you have over 1000 transactions. Specify the last transaction signature in before: <string> - start searching backward from this transaction signature. If not provided the search starts from the top of the highest max confirmed block.

More information here

2
  • 1
    yeah doing all of these already but no luck — thinking it has something to do with rent and rent-exempt accounts
    – 0xMertimus
    Commented Aug 19, 2022 at 13:53
  • I have not idea if this is anyhow connected but I have got recently a strange observation around the balances: solana.stackexchange.com/questions/5666/…
    – chalda
    Commented Feb 16, 2023 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.