Hi,
I was wondering if anyone knew how to use NNS locally to access the IC exchange rate to be used for a project?
Thanks.
Hi,
I was wondering if anyone knew how to use NNS locally to access the IC exchange rate to be used for a project?
Thanks.
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.
Get_value(xdr_per_ipc).
this is protobuf; not candid.
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
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).
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 IC.rocks 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.
Quick update: The change that I mentioned above is now live.
You can request the exchange rate directly from the cycles minting canister (rkp4c-7iaaa-aaaaa-aaaca-cai
).
I’m trying to get the XDR-to-ICP exchange rate through the minting canister using the method that previously existed on the registry canister (get_icp_to_cycles_conversion_rate()), but am getting an error that this method doesn’t exist on the minting canister. I wonder if it’s been renamed?
The function is called get_icp_xdr_conversion_rate()
as you can see here.
You can test it using dfx
:
dfx canister --no-wallet --network ic call --query "rkp4c-7iaaa-aaaaa-aaaca-cai" get_icp_xdr_conversion_rate
Where can we find the .did files for this canister?
ic.rocks doesn’t show it.
You can find it here : Canlista - NNS Cycles Minting