We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dfx start is running: and dfx deploy backend ok code in canister:
dfx start
dfx deploy backend
#[query(guard = "user_owner_guard")] pub fn greet_test()->String{ ic_cdk::println!("got greet_test() call"); return "hello agent!".to_string(); }
async fn greet_test(agent: Agent, canister_id: Principal) -> String { let response = agent .query(&canister_id, "greet_test") .with_arg(candid::encode_one(()).unwrap()) .call() .await; match response { Ok(data) => { let ret = String::from_utf8(data).unwrap(); println!("{}", ret); return ret; } Err(e) => { let ret = format!("####An error occurred: {:?}", e); println!("{}", ret); return ret; } } }
running in ic mode perfect ok. but local agent fails:
async fn init_agent() -> (Principal, Agent, String) { let controller = String::from("btwlz"); let args: Vec<String> = env::args().collect(); let online_mode = &args[1]; let url_local = String::from("http://127.0.0.1:40010"); let url_ic = String::from("https://ic0.app/"); let canister_id_local = Principal::from_text("bkyz2-fmaaa-aaaaa-qaaaq-cai").unwrap(); let canister_id_ic = Principal::from_text("v7g7o-oiaaa-aaaag-qcj3q-cai").unwrap(); let url; let canister_id; if online_mode == "0" { println!("local network mode"); url = url_local; canister_id = canister_id_local; } else if online_mode == "1" { println!("ic network mode"); url = url_ic; canister_id = canister_id_ic; } else { panic!("args input err!!"); } // !INFO this need use input passwd in terminal if have passwd. takes about 3s // to run let identity = get_dfx_identity(&controller); let agent = build_ic_agent(url, identity).await; (canister_id, agent, online_mode.to_string()) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
dfx start
is running:and
dfx deploy backend
okcode in canister:
running in ic mode perfect ok. but local agent fails:
The text was updated successfully, but these errors were encountered: