Decentralized DAB by NFID Labs

We’ve built a v1 governable ICRC-1 token API that we’re already using in NFID Wallet, is being used by the Bity team in their wallet, and that we’d like to roll out for the whole ecosystem after a bit of additional polish.

There’s something wonky with our dfx metadata so for now you’ll have to access the get_all_icrc1_canisters endpoint for the zjahs-wyaaa-aaaal-qjuia-cai canister through the candid UI with the did pasted at the bottom (sorry, don’t have forum permission to post the file itself).

@nadiein and I have a couple of questions regarding token data retrieval:

  1. What’s the most reliable method to fetch all SNS tokens?
    We’ve found two endpoints, but neither solves the issue completely:
  1. How can we determine if an ICRC-1 token has an index canister?
    From the limited research we’ve done so far, there’s not yet a reliable answer.

Thanks, everyone!

did file for canister zjahs-wyaaa-aaaal-qjuia-cai:

type Category = variant {
    Sns;
    Known;
    Spam;
    ChainFusionTestnet;
    ChainFusion;
    Community;
    Native;
};

type Conf = record {
    controllers : opt vec principal;
    im_canister : opt principal;
};

type ICRC1 = record {
    logo : opt text;
    name : text;
    ledger : text;
    category : Category;
    index : opt text;
    symbol : text;
    decimals : nat8;
    fee : nat;
};

type ICRC1Request = record {
    logo : opt text;
    name : text;
    ledger : text;
    index : opt text;
    symbol : text;
    decimals : nat8;
    fee : nat;
};service : (opt Conf) -> {
    get_all_icrc1_canisters : () -> (vec ICRC1) query;
    replace_icrc1_canisters : (vec ICRC1) -> ();
    store_new_icrc1_canisters : (vec ICRC1) -> ();
    store_icrc1_canister : (ICRC1Request) -> ();
    sync_controllers: () -> (vec text);
}
7 Likes
  1. With the first step, you’re halfway there. https://sns-api.internetcomputer.org/api/v1/snses returns the root canisters of each SNS, and if you then query https://sns-api.internetcomputer.org/api/v1/snses/<root_canister_id>, you’ll get information about the canisters of that particular SNS, e.g., for the first one in the list BOOM DAO, https://sns-api.internetcomputer.org/api/v1/snses/xjngq-yaaaa-aaaaq-aabha-cai . Then look for ledger_canister_id (and potentially index_canister_id).
  2. This is not currently possible. We’re looking into options for this.
1 Like

You can get the list of SNSes (and canister IDs and a lot more) from a paginated list on the SNS aggregator.
The first page is here: https://3r4gx-wqaaa-aaaaq-aaaia-cai.icp0.io/v1/sns/list/page/0/slow.json
There are currently 4 pages.

1 Like

do we already have ideas how to provide this?

hello @mathiasb
we checked the option that you suggested, however, we can get only 20 tokens, disregarding that currently, 30 projects passed SNS.


we will take a look at the SNS aggregator, but will prefer the original endpoint to get the correct data (;

Thanks for the update, @nadiein ! With the following script I am able to list 30 SNS index canisters:

#!/bin/bash
export DFX_WARNING="-mainnet_plaintext_identity"
ROOT_CANISTERS=$(curl -s "https://sns-api.internetcomputer.org/api/v1/snses?max_sns_index=99&offset=0&limit=100&include_swap_lifecycle=LIFECYCLE_COMMITTED" | jq -r ".data[].root_canister_id")
for root_canister in ${ROOT_CANISTERS};
do
  data=$(curl -s "https://sns-api.internetcomputer.org/api/v1/snses/$root_canister")
  name=$(printf "%-20s%s\n" `echo $data | jq -r ".name"`)
  canister_type_and_id=$(echo ${data} | jq -cr '.canisters[] | "\(.canister_type):\(.canister_id)"')
  for id in $canister_type_and_id
  do
    if [[ $id == *"index"* ]]
    then
      name=$(echo $name | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//' | sed 's/ /-/g' | tr '[:lower:]' '[:upper:]')
      echo -e "$name: \t$id" | sed 's/index://g'
    fi
  done
done

Based on what you wrote and your screenshot, I cannot say where the issue is. Maybe you’re not specifying a large enough limit, and only get information from 20 SNSs in the response to your query?

There is ongoing work on the ICRC-106 standard that allows for retrieving information about the index canister ID from its ledger canister. There’s also some discussion around it in this forum thread. At this time I would expect the functionality to be available in January 2025.

Since there is currently no standard for the ledger index, ICRC-106 is more of a stop-gap solution for supporting existing use cases. There are plans to work on an index standard as a follow-up.

1 Like