What is a ledger offset?

Hi team,

I read in the ledger api documentation that there is a ledger offset.
I got some issue understanding it at the beginning.

May I know what exactly is that ledger offset ?




The offset is an ever-growing number assigned by the participant to each transaction as they are received from the ledger. The state of a ledger (i.e. the set of active contracts) as exposed by the Ledger API is valid at a specific offset, which is why the last message you receive when calling the ActiveContractsService is precisely that offset. In this way, the client can keep track of the relevant state without needing to invoke the ActiveContractsService again, by starting to read transactions from the given offset.

Note that the offset is also useful to perform crash recovery, by persisting the relevant state and the offset at which it was valid and resuming from there in case of a crash.


Cheers as usual Stef’


@stefanobaghino-da The docs don’t seem to mention that the offset is a number though - they just seem to indicate it would be lexicographically comparable. Could you please point me in the direction of where you see it’s a number?


I think I might have wanted to keep it casual and simple in order to explain it. It’s definitely a byte array. Thinking of it as a number is definitely not accurate but hopefully good enough to give an intuition of it. Thanks for keeping me honest!