| Crates.io | ic-agent-canister-runtime |
| lib.rs | ic-agent-canister-runtime |
| version | 0.1.1 |
| created_at | 2025-11-24 09:17:59.873431+00 |
| updated_at | 2025-12-09 12:25:00.492941+00 |
| description | Implementation of a canister runtime of the Internet Computer for `ic-agent` |
| homepage | https://github.com/dfinity/canhttp |
| repository | https://github.com/dfinity/canhttp |
| max_upload_size | |
| id | 1947561 |
| size | 89,918 |
ic-agent-canister-runtimeLibrary that implements the ic_canister_runtime crate's Runtime trait using ic-agent.
This can be useful when, e.g., contacting a canister via ingress messages instead of via another canister.
Add this to your Cargo.toml (see crates.io for the latest version):
ic-agent-canister-runtime = "0.1.0"
ic-canister-runtime = "0.1.0"
Then, use the library to abstract your code making requests to canisters as follows:
use ic_agent_canister_runtime::AgentRuntime;
use ic_canister_runtime::Runtime;
let agent = ic_agent::agent::Agent::builder().build().unwrap();
let runtime = AgentRuntime::new(&agent);
// Make a request to the `http_request` example canister's `make_http_post_request` endpoint
// See: https://github.com/dfinity/canhttp/tree/main/examples/http_canister
let http_request_result: String = runtime
.update_call(canister_id, "make_http_post_request", (), 0)
.await
.expect("Call to `http_canister` failed");
assert!(http_request_result.contains("Hello, World!"));
assert!(http_request_result.contains("\"X-Id\": \"42\""));
See the Rust documentation for more details.
This project is licensed under the Apache License 2.0.