If my Ledger.query_blocks response has a certificate, what does it mean?

Does it mean my transaction is completed? Docs said I can use the “certificate” to verify the transaction, but how?

Can somebody explain to me what will be missing from the Response object if the transaction is incomplete? and what will appear if the transaction is complete? How did the Dashboard determine that a transaction is completed?

image

Thank you.

Hi @kayicp
This is explained in detail in the Getting ledger blocks section of the ICP ledger specification.
In brief: the certificate that is returned with each query_blocks call is a certificate for the entire chain of ICP transactions, and not for the blocks returned in the specific query. In more detail, the certificate is a signature on the hash of the last block in the ICP ledger. It can be used to verify the entire history of transactions on the ledger: verify that the blocks in the ledger are properly chained (i.e. each block contains the hash of the previous block) and then verify that the certificate is a valid signature on the hash of the last block. This guarantees that the entire chain is genuine, but to carry out the verification you must have the entire chain.

Notice that you get the certificate only if you invoke the query_blocks method in a non-replicated way (as a query).

(In passing, this is what the dashboard, or rather the Rosetta node used by the dashboard, does: it fetches the entire chain via unreplicated queries and then verifies the certificate on the last block.)

If you don’t care about the entire ledger and only want the guarantee wrt to a few transactions, then you can call the query_blocks method in replicated mode (i.e. as an update call). In this case, the reply will be signed by the entire subnetwork and you have the guarantee that it is genuine.

I hope this helps.

3 Likes