# Offset Error in DAML code

**URL:** <https://forum.canton.network/t/offset-error-in-daml-code/687>\
**Category:** App Development\
**Tags:** sandbox\
**Created:** [June 19, 2020, 10:15am UTC](https://forum.canton.network/t/offset-error-in-daml-code/687 "2020-06-19T10:15:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sneha](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/sneha/32/543_2.png) [@Sneha](https://forum.canton.network/u/Sneha)\
**Post date:** [June 19, 2020, 10:15am UTC](https://forum.canton.network/t/offset-error-in-daml-code/687/1 "2020-06-19T10:15:23Z")

</div>

Hi Everyone,

From the slack to discussions group. 🙂

Here is the error i see in daml sdk even after running daml sandbox-calssic

could some one help where am missing here

```haskell
java.lang.IllegalArgumentException: cannot parse HexString 0
        at com.daml.platform.ApiOffset$.$anonfun$fromString$1(ApiOffset.scala:19)
        at scala.util.Either.fold(Either.scala:192)
        at com.daml.platform.ApiOffset$.fromString(ApiOffset.scala:20)
        at com.daml.platform.index.LedgerBackedIndexService.$anonfun$convertOffset$1(LedgerBackedIndexService.scala:114)
        at com.daml.platform.index.LedgerBackedIndexService.between(LedgerBackedIndexService.scala:123)
        at com.daml.platform.index.LedgerBackedIndexService.transactionTrees(LedgerBackedIndexService.scala:76)
        at com.daml.platform.apiserver.TimedIndexService.$anonfun$transactionTrees$1(TimedIndexService.scala:93)
        at com.daml.metrics.Timed$.source(Timed.scala:46)
        at com.daml.platform.apiserver.TimedIndexService.transactionTrees(TimedIndexService.scala:93)
        at com.daml.platform.apiserver.services.transaction.ApiTransactionService.$anonfun$getTransactionTrees$1(ApiTransactionService.scala:94)
        at com.daml.logging.LoggingContext$.withEnrichedLoggingContext(LoggingContext.scala:23)
        at com.daml.platform.apiserver.services.transaction.ApiTransactionService.getTransactionTrees(ApiTransactionService.scala:87)
        at com.daml.platform.server.api.services.grpc.GrpcTransactionService.$anonfun$getTransactionTreesSource$3(GrpcTransactionService.scala:76)
        at scala.util.Either.fold(Either.scala:191)
        at com.daml.platform.server.api.services.grpc.GrpcTransactionService.$anonfun$getTransactionTreesSource$1(GrpcTransactionService.scala:74)
        at akka.stream.impl.fusing.Map$$anon$1.onPush(Ops.scala:54)
        at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:541)
        at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:527)
        at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:390)
        at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:624)
        at akka.stream.impl.fusing.ActorGraphInterpreter$SimpleBoundaryEvent.execute(ActorGraphInterpreter.scala:55)
        at akka.stream.impl.fusing.ActorGraphInterpreter$SimpleBoundaryEvent.execute$(ActorGraphInterpreter.scala:51)
        at akka.stream.impl.fusing.ActorGraphInterpreter$RequestMore.execute(ActorGraphInterpreter.scala:273)
        at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:599)
        at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:768)
        at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:783)
        at akka.actor.Actor.aroundReceive(Actor.scala:533)
        at akka.actor.Actor.aroundReceive$(Actor.scala:531)
        at akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:690)
        at akka.actor.ActorCell.receiveMessage(ActorCell.scala:573)
        at akka.actor.ActorCell.invoke(ActorCell.scala:543)
        at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:269)
        at akka.dispatch.Mailbox.run(Mailbox.scala:230)
        at akka.dispatch.Mailbox.exec(Mailbox.scala:242)
        at java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source)
        at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
        at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)

```

---

<div class="post-metadata">

**Author:** ![stefanobaghino-da](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stefanobaghino-da/32/7057_2.png) [@stefanobaghino-da](https://forum.canton.network/u/stefanobaghino-da)\
**Post date:** [June 19, 2020, 10:47am UTC](https://forum.canton.network/t/offset-error-in-daml-code/687/2 "2020-06-19T10:47:15Z")

</div>

Hello and welcome, @Sneha.

If I got it correctly from the previous discussion you saved the offsets from a previous run and you are trying to re-use those externally saved offsets to retrieve specific transactions.

As part of going from 0.x to 1.x, we changed what offset mean and how they work, which means that using an externally persisted offset across major version cannot be done directly.

The release notes for 1.0.0 go in greater detail about it, in particular [here](https://docs.daml.com/support/release-notes.html#id26).

_The following applies exclusively to the sandbox (as offsets don’t necessarily match across ledger implementations):_ you can still migrate your own persisted offsets to the new format to make sure they match the new ones. In order to do so, you have to convert the offsets you persisted to an hexadecimal number, turn it into a string and left-pad it with `0`s so that the resulting string is 16 characters long (kudos to @gerolf for the suggestion in this regard).

---

<div class="post-metadata">

**Author:** ![Sneha](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/sneha/32/543_2.png) [@Sneha](https://forum.canton.network/u/Sneha)\
**Post date:** [June 19, 2020, 10:50am UTC](https://forum.canton.network/t/offset-error-in-daml-code/687/3 "2020-06-19T10:50:57Z")

</div>

Thank you @stefanobaghino-da.  
I will go through the link and also try the last point it seems interesting.  
I will get back if i face any issue.  
Thanks for the help.

---

<div class="post-metadata">

**Author:** ![Sneha](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/sneha/32/543_2.png) [@Sneha](https://forum.canton.network/u/Sneha)\
**Post date:** [June 19, 2020, 12:55pm UTC](https://forum.canton.network/t/offset-error-in-daml-code/687/4 "2020-06-19T12:55:25Z")

</div>

Thanks @stefanobaghino-da, it worked after leading zeros and making string to 16 characters.

Thanks to @gerolf

---

<div class="post-metadata">

**Author:** ![Sneha](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/sneha/32/543_2.png) [@Sneha](https://forum.canton.network/u/Sneha)\
**Post date:** [June 19, 2020, 1:48pm UTC](https://forum.canton.network/t/offset-error-in-daml-code/687/5 "2020-06-19T13:48:15Z")

</div>

@stefanobaghino-da, in the link you have provide above doesn’t say anything about hexa value for offset. Is it mentioned somehwere?

Can you please point me over there.

---

<div class="post-metadata">

**Author:** ![stefanobaghino-da](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stefanobaghino-da/32/7057_2.png) [@stefanobaghino-da](https://forum.canton.network/u/stefanobaghino-da)\
**Post date:** [June 19, 2020, 1:53pm UTC](https://forum.canton.network/t/offset-error-in-daml-code/687/6 "2020-06-19T13:53:44Z")

</div>

That is because that format is specific for the Sandbox (as you can see [here](https://docs.daml.com/1.2.0/app-dev/grpc/proto-docs.html#com-daml-ledger-api-v1-ledger-offset-proto) the Ledger API reference also simply refers to it being an opaque string) and the user is normally not supposed to do any kind of processing on it.

Note that the migration mentioned above makes sense only when using the Sandbox and only when migrating from 0.x to 1.x. In general, referring to offsets across major versions is not necessarily supported.
