Skip to content
Discussions/App Development/What is a ledger offset?Forum ↗

What is a ledger offset?

App Development5 posts916 views12 likesLast activity Feb 2023
JA
jaypeedaOP
Jul 2021

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 ?

Cheers,

JP

ST
stefanobaghino-da
Jul 2021

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.

JA
jaypeeda
Jul 2021

Cheers as usual Stef’

MR
Mr_Mannoroth
Feb 2023
stefanobaghino-da:

The offset is an ever-growing number

@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?

ST
stefanobaghino-da
Feb 2023

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!

← Back to Discussions