goose
May 26, 2022, 11:39am
1
I use rust to write a canist and deploy it to the IC main network. Why the Canister Interface cannot be viewed in the rocks browser? My cansiter: Principal qy2to-tqaaa-aaaai-qiyjq-cai | ic.rocks .
Maybe the did file not upload successfully? How to upload a did file?
OGY canister ,Canister Interface can be viewed.
Ori
May 27, 2022, 10:29pm
2
For rust canisters you can add a __get_candid_interface_tmp_hack() method to your actor that serves the .did file, like this:
https://github.com/dfinity/ic/blob/c48280bbeec347a6b73160199566c612bd8ccbf7/rs/nns/governance/canister/canister.rs#L944
Motoko canisters automatically provide this method for you.
Then you’ll be able to see it on ic.rocks (and here: https://k7gat-daaaa-aaaae-qaahq-cai.ic0.app/canister/qy2to-tqaaa-aaaai-qiyjq-cai )
1 Like
goose
May 30, 2022, 1:25am
3
#[query(name = "__get_candid_interface_tmp_hack")]
fn export_candid() -> String {
ic_cdk::export::candid::export_service!();
__export_service()
}
#[cfg(any(target_arch = "wasm32", test))]
fn main() {}
#[cfg(not(any(target_arch = "wasm32", test)))]
fn main() {
ic_cdk::export::candid::export_service!();
std::print!("{}", __export_service());
}