How to query blocks using the archive canister interface?

I’m trying to retrieve ledger transactions from archive canister using the query method “get_blocks”:

https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.ic0.app/?id=qjdve-lqaaa-aaaaa-aaaeq-cai

I tried many parameter combinations:

For small values of “start” parameter (e.g. 100), I get an error: “Not an option type”
For very large values of “start” parameter (e.g. 10000000), I get “Ok” but empty blocks

How can we query blocks using the archive canister interface?

I found out that using dfx it works, but the same call does not work using @dfinity\agent or the web service of my previous message:

This works:
dfx canister --network ic call qjdve-lqaaa-aaaaa-aaaeq-cai get_blocks ‘(record {start = 1:nat64; length = 2:nat64})’

This does not work:
https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.ic0.app/?id=qjdve-lqaaa-aaaaa-aaaeq-cai

This does not work:
... const start2 = 10000000; const length2= 2; const GetBlocksArgsArchive = { start: start2, length: length2, }; const res_archive = await archive.get_blocks(GetBlocksArgsArchive);

Why is dfx the only viable way to access the archive canister?

Definitively not intended - looks like a bug. I’ll ping the relevant team(s)

1 Like

Hi Severin,

Any update on this?

Thanks,

Nathan.

No idea, I’ll ask again.

That might be because we return operation : variant { ... } where op : opt variant { ... } is expected. However, that shouldn’t be a problem according to the Candid spec. Decoders should treat T as a legitimate substitute for opt T.

not (null <: <datatype'>)
<datatype> <: <datatype'>
-----------------------------
<datatype> <: opt <datatype'>

That seems to be a bug in JS candid decoder.