I’m trying to call canister method from a rust program/axum server endpoint,
I have deployed canister code locally using dfx start command.
I followed code given at ic-agent docs - ic_agent - Rust
In my canister code:
lib.rs
#[query]
fn get_some_id() -> String {
"123".to_owned()
}
ic_backend.did
service : {
get_some_id : () -> (text) query;
}
And in my main.rs i have function which connects to canister using ic-agent
async fn connect_to_canister() -> String {
// connecting local replica
let agent = Agent::builder()
.with_url("http://127.0.0.1:4943")
.with_identity(AnonymousIdentity)
.build()
.unwrap();
agent.fetch_root_key().await.unwrap();
let canister_id = Principal::from_text("local-canister-id-cai").unwrap();
let empty_args: Vec<u8> = Encode!();
// OR
// let empty_args: Vec<u8> = Encode!( () );
// OR
// let empty_args: Vec<u8> = vec![68, 73, 68, 76, 0, 0];
match agent
.query(&canister_id, "get_some_id")
.with_arg(empty_args)
.call()
.await
{
Ok(resp) => Decode!(resp.as_slice(), String).unwrap(),
Err(error) => error.to_string(),
}
}
Its giving me error:
Query signature verification failed.
Is this issue related to method signature mismatch? Or is it related to identity or certificate?
Also, how do I debug it from replica side, as there are no debug logs coming up when i use ‘dfx start -v’