Accessing the exchange rate on the IC, Locally


I was wondering if anyone knew how to use NNS locally to access the IC exchange rate to be used for a project?


Do you mean the ICPXDR exchange rate? You can get that from the NNS canister call get_icp_to_cycles_conversion_rate() which returns the current ICPXDR rate (which is used to calculate how many cycles will be generated per ICP).

We use this with StoicWallet, when you are topping up canisters you can view the exact rate (currently ~31T cycles per ICP).


Yes for the ICPXDR exchange rate. How do I access a NNS canister call? Do I need to download anything or can I just code it into Motoko in a price oracle canister? Thanks for your help.

From motoko, you can call the actor function. Requires some work, but it’s not too hard you can get all the info from the docs. I can post an example later when I’m free

That would be great, thank you!

Anyone know where the off-chain price oracle is hosted? AWS? Server in Dfinity’s basement?

I believe the deterministic xdr_per_ipc is on chain.


this is protobuf; not candid.

1 Like

Something like (in motoko):

type NNSActor = actor { get_icp_to_cycles_conversion_rate : () -> (nat64) };

let nns: NNSActor = actor("qoctq-giaaa-aaaaa-aaaea-cai");
let icpxdr : Nat64 = await nns.get_icp_to_cycles_conversion_rate();

So there’d be two canisters needed, one for NNS and one for the price oracle?
qoctq-giaaa-aaaaa-aaaea-cai would be the canister ID for the NNS?

The example I pasted above should do what you want on its own without a second canister

1 Like

Your question in discussed in this thread (to which I provided an answer):

These oracles are run on multiple independent data centers (neither on AWS nor in DFINITY’s basement). :slightly_smiling_face:

1 Like

this is in nns-ui canister, But the source code is not opened.

Ah, totally missed this. Thanks.

Yeah NNS canister, I pulled the candid from for it

Hey everyone!
If you are using the exchange rate in your projects, be aware that the mechanism will change in the upcoming weeks.
Specifically, the exchange rate will no longer be maintained in the NNS registry. Instead, the cycles minting canister will store it directly and make it available using the same interface.

1 Like