1

I'm trying to understand if JSON RPC function getTransaction with { commitment: "confirmed" } config is safe enough to say transaction is valid.

I want to check if user A sent 1 SOL to user B. So I'll check a lot of fields from getTransaction() response. Errors, balance changes etc.

But what is the risk if I check the response I get with commitment "confirmed" instead of commitment "finalized"?

2 Answers 2

3

Yes, confirmed is safe enough. The chance of a rollback is slim as a super majority of nodes have already voted on the transaction.

Using the confirmed commitment is recommended if you have dependent transactions as it balances speed with rollback safety.

The commitment describes how finalized a block is at that point in time. When querying the ledger state, it's recommended to use lower levels of commitment to report progress and higher levels to ensure the state will not be rolled back.

If you want "total safety", you should go with finalized

1

Whether any confirmation commitment level is "safe" or not is application dependent. What is safe for a 1 lamport transaction is not likely safe for 1M SOL transaction. You should understand the commitment levels sufficiently to understand which is adequate for the task at hand

1
  • Do you know of any good resources for trying to understand the implications of the different commitment levels further? Thanks!
    – daoplays
    Commented Aug 27, 2022 at 20:17

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.