# ICRC1/2 Ledger Archives: How to get the length of the archives?

**URL:** <https://forum.dfinity.org/t/icrc1-2-ledger-archives-how-to-get-the-length-of-the-archives/35301>\
**Category:** Rust\
**Created:** [September 19, 2024, 9:07am UTC](https://forum.dfinity.org/t/icrc1-2-ledger-archives-how-to-get-the-length-of-the-archives/35301 "2024-09-19T09:07:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dantol29](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dantol29/32/20601_2.png) [@dantol29](https://forum.dfinity.org/u/dantol29)\
**Post date:** [September 19, 2024, 9:07am UTC](https://forum.dfinity.org/t/icrc1-2-ledger-archives-how-to-get-the-length-of-the-archives/35301/1 "2024-09-19T09:07:54Z")

</div>

```auto
archives: () → (record {archives:vec record {canister_id:principal}}) query

```

It does not have start and end, like other standards do. The archive itself also does not store chain\_length and first\_index…

Is it even possible or do I have to query random numbers until I find the boundaries?  
Perhaps, every ICRC1 archive has the same length?

# ICP Ledger Canister as example

[https://dashboard.internetcomputer.org/canister/ryjl3-tyaaa-aaaaa-aaaba-cai](https://dashboard.internetcomputer.org/canister/ryjl3-tyaaa-aaaaa-aaaba-cai)

I know there is an index canister, but not all ledgers have them

---

<div class="post-metadata">

**Author:** ![jennifertran](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jennifertran/32/11558_2.png) [@jennifertran](https://forum.dfinity.org/u/jennifertran)\
**Post date:** [September 19, 2024, 5:59pm UTC](https://forum.dfinity.org/t/icrc1-2-ledger-archives-how-to-get-the-length-of-the-archives/35301/2 "2024-09-19T17:59:32Z")

</div>

The ICRC 1/2 ledgers are different. I suggest you looking at an ICRC1/2 ledger. For example, let’s take a look at ELNA:

> **[Canister: ELNA AI Ledger](https://dashboard.internetcomputer.org/canister/gemj7-oyaaa-aaaaq-aacnq-cai)**
>
> Canister smart contract running on the Internet Computer blockchain.

You will see the `archives` method. By calling it, you will see this response:

```auto
(
  vec {
    record {
      block_range_end = 38_999 : nat;
      canister_id = principal "dyxt2-fqaaa-aaaaq-aacsa-cai";
      block_range_start = 0 : nat;
    };
  },
)

```

This indicates that blocks 0 to 38,999 are archived in canister `dyxt2-fqaaa-aaaaq-aacsa-cai`.

You can see the public methods on the archive canister `dyxt2-fqaaa-aaaaq-aacsa-cai`.

> **[Canister: ELNA AI Archive](https://dashboard.internetcomputer.org/canister/dyxt2-fqaaa-aaaaq-aacsa-cai)**
>
> Canister smart contract running on the Internet Computer blockchain.

Hope this helps! Please let us know if you need more clarification.

---

<div class="post-metadata">

**Author:** ![dantol29](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dantol29/32/20601_2.png) [@dantol29](https://forum.dfinity.org/u/dantol29)\
**Post date:** [September 20, 2024, 10:12pm UTC](https://forum.dfinity.org/t/icrc1-2-ledger-archives-how-to-get-the-length-of-the-archives/35301/3 "2024-09-20T22:12:35Z")

</div>

Thanks for the answer! But why ICP ledger canister does not have start and end?  
archives: () → (record {archives:vec record {canister\_id:principal}}) query

I just gonna use its index canister)

---

<div class="post-metadata">

**Author:** ![jennifertran](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jennifertran/32/11558_2.png) [@jennifertran](https://forum.dfinity.org/u/jennifertran)\
**Post date:** [September 20, 2024, 11:14pm UTC](https://forum.dfinity.org/t/icrc1-2-ledger-archives-how-to-get-the-length-of-the-archives/35301/4 "2024-09-20T23:14:31Z")

</div>

I believe that it has to do with the implementation of [ICRC3](https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-3/README.md) by other tokens which makes it easier and required to expose the start and last archive blocks.

---

<div class="post-metadata">

**Author:** ![jennifertran](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jennifertran/32/11558_2.png) [@jennifertran](https://forum.dfinity.org/u/jennifertran)\
**Post date:** [September 20, 2024, 11:32pm UTC](https://forum.dfinity.org/t/icrc1-2-ledger-archives-how-to-get-the-length-of-the-archives/35301/5 "2024-09-20T23:32:12Z")

</div>

I’ll see if the team has a better way but here’s an easy workaround for now:

1. Call `archives` method on the NNS Ledger Canister to view the canister IDs of the archives:

```auto
(
  record {
    archives = vec {
      record { canister_id = principal "qjdve-lqaaa-aaaaa-aaaeq-cai" };
      record { canister_id = principal "qsgjb-riaaa-aaaaa-aaaga-cai" };
      record { canister_id = principal "q4eej-kyaaa-aaaaa-aaaha-cai" };
    };
  },
)

```

1. Call `query_blocks` on the NNS Ledger Canister with start `0` and length `14_361_000`:

```auto
(
  record {
    certificate = opt blob "\d9\d9\f7\a2\64\74\72\65\65\83\01\83\01\83\01\82\04\58\20\a6\5a\fa\38\e2\24\22\88\63\a8\9e\bb\73\cf\e5\5c\f9\c0\b5\e6\c8\f8\75\6c\39\88\cd\78\39\76\5e\8b\83\02\48\63\61\6e\69\73\74\65\72\83\01\83\01\83\01\82\04\58\20\d3\49\aa\33\7f\1d\e1\a6\30\c1\e3\77\e3\51\cf\9b\45\f4\58\50\76\e9\33\f6\4b\5e\3e\71\8f\9b\ea\ad\83\01\83\02\4a\00\00\00\00\00\00\00\02\01\01\83\01\83\01\83\02\4e\63\65\72\74\69\66\69\65\64\5f\64\61\74\61\82\03\58\20\24\9f\82\ca\76\48\cb\8d\07\8b\d5\de\88\92\5b\ef\6c\d5\4b\4d\a9\bc\64\c3\12\02\c0\79\f9\3f\b0\5a\82\04\58\20\d8\f6\4f\7a\fc\a6\a5\5d\4e\e6\de\d9\b0\20\0b\ac\66\51\ca\f4\c7\a1\92\02\12\b5\a0\3c\9b\f1\df\36\82\04\58\20\7a\98\5b\46\88\ba\5c\69\25\31\61\3e\e3\ad\7e\95\a5\e1\20\ea\99\38\90\d0\d0\ad\28\eb\cf\53\b6\20\82\04\58\20\6a\8a\28\cd\b0\f9\91\9c\b2\38\b1\4a\d2\ae\59\8e\ab\cd\7a\61\7e\08\04\4a\5a\ad\e6\d7\05\c4\9b\ae\82\04\58\20\6e\76\12\7f\bb\ea\29\ba\eb\0f\7a\81\61\ee\12\6b\19\3a\a7\a3\f6\95\e3\c3\41\96\43\71\dc\d2\b6\d3\82\04\58\20\22\89\ef\49\dc\cc\e1\87\cb\6f\0e\7b\2a\a3\2d\24\1e\a0\ff\8c\36\8e\39\ff\d9\97\e8\47\14\98\aa\b7\82\04\58\20\a6\50\ba\1e\09\80\b9\9c\eb\c3\6d\af\49\1b\72\8c\c6\97\de\92\59\fe\48\3a\4f\26\09\26\f1\5a\ef\34\83\01\82\04\58\20\94\a8\dd\4e\19\d2\0b\42\81\d6\8b\60\98\b8\39\0e\00\47\8e\30\fe\61\ba\03\7f\8a\7a\f6\06\44\a0\3e\83\02\44\74\69\6d\65\82\03\49\b0\f3\e2\a9\c9\f2\c5\fb\17\69\73\69\67\6e\61\74\75\72\65\58\30\83\ab\11\6a\bf\70\9a\b2\0c\5c\48\09\40\45\5e\f2\b7\82\9e\b0\d2\9b\21\52\ea\e4\22\ba\86\0e\36\bf\43\44\78\87\ad\64\28\c9\b2\fe\4e\b4\e5\97\e0\89";
    blocks = vec {};
    chain_length = 14_362_229 : nat64;
    first_block_index = 14_361_000 : nat64;
    archived_blocks = vec {
      record {
        callback = func "qjdve-lqaaa-aaaaa-aaaeq-cai".get_blocks;
        start = 0 : nat64;
        length = 7_051_992 : nat64;
      };
      record {
        callback = func "qsgjb-riaaa-aaaaa-aaaga-cai".get_blocks;
        start = 7_051_992 : nat64;
        length = 6_856_439 : nat64;
      };
      record {
        callback = func "q4eej-kyaaa-aaaaa-aaaha-cai".get_blocks;
        start = 13_908_431 : nat64;
        length = 452_569 : nat64;
      };
    };
  },
)

```

You will see that `qjdve-lqaaa-aaaaa-aaaeq-cai` holds blocks `0` to `7_051_991`, `qsgjb-riaaa-aaaaa-aaaga-cai` blocks `7_051_992` to `13_908_430` and `q4eej-kyaaa-aaaaa-aaaha-cai` `13_908_431` to `14_360_999`.
