List subnets programmatically

How do I programmatically find the list of subnets?

3 Likes

here is how ic-admin gets it from the registry canister:

3 Likes

Thanks @yvonneanne. Those don’t seem to be functions exposed in public crates, so I’m not sure if everything would need to be copied. :thinking:

PS: Not an urgent question, it can definitely wait until working hours.

1 Like

what do you need the list for?
the CMC has a public query method to get default subnets (I’m not sure what default subnets are… maybe the ones new canisters would be on at random if no additional conditions apply?)
https://dashboard.internetcomputer.org/canister/rkp4c-7iaaa-aaaaa-aaaca-cai

4 Likes

Ah, that’s nice! I also noticed it, but like you, I was confused about what ā€˜default’ means. If that’s the public list, that should work. Thanks!

Yes, that’s exactly what it is. You can see that the output matches what has been defined in the latest proposal.

2 Likes

I’m still a bit unsure about what ā€˜default’ means. I wanted to add it to DFINITY’s ic-js, but I’m not sure how I should document it. The Rust code is also undocumented. What could be an accurate description for it?

Maybe this explanation by Severin helps: NNS Updates Dec 1, 2023 - #8 by Severin

1 Like

Thanks, now I understand how ā€œdefaultā€ is used. But is it safe to say that ā€œdefaultā€ equals the ā€œpublicā€ subnets (as in the proposal shared above)?

Or are the ā€œdefaultā€ subnets a subset of the ā€œpublicā€ subnets?

1 Like

In code and proposal public == default is valid. IMO it would be more correct to also include the ones publicly accessible by specifying a subnet type, but oh well…

1 Like

I’m not entirely I get everything but, it answered my questions. Gonna work with the default. Thanks for the explanation!

2 Likes