Crates.io | icx |
lib.rs | icx |
version | 0.39.0 |
source | src |
created_at | 2021-04-16 02:33:08.416761 |
updated_at | 2024-10-18 17:09:15.972146 |
description | CLI tool to call canisters on the Internet Computer. |
homepage | https://docs.rs/icx |
repository | https://github.com/dfinity/agent-rs |
max_upload_size | |
id | 385174 |
size | 99,466 |
icx
A command line tool to use the ic-agent
crate directly. It allows simple communication with
the Internet Computer.
icx
To install icx
you will have to build it locally, using cargo
. Make a clone of this repository,
then in it simply run cargo build
:
git clone https://github.com/dfinity/agent-rust.git
cd agent-rust
cargo build
The output executable will be in target/debug/icx
.
icx
To get help, simply use icx --help
.
To read a PEM file, you can pass it with the --pem
argument. The PEM file must be a valid
key that can be used for the Internet Computer signing and validation.
For non-IC networks, pass --fetch-root-key
to fetch the root key. When this argument is not present,
icx uses the hard-coded public key.
To call the management canister's create_canister
function, you can use the following:
icx update aaaaa-aa create_canister
If you have a candid file, you can use it to validate arguments. Pass it in with the
--candid=path/to/the/file.did
argument:
icx query 75hes-oqbaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q greet --candid=~/path/greet.did '("World")'
Pass --serialize
when use icx update
and icx query
will serialize the signed canister call message as json.
The output will print to stdout. When use icx update
, a corresponding request_status message is also generated and printed to stderr.
In the default IC project generated with dfx new
and the local emulator has started with dfx start --background
.
icx --fetch-root-key update --serialize rwlgt-iiaaa-aaaaa-aaaaa-cai greet '("everyone")' > output.txt
head -n 1 output.txt > update.json
tail -n 1 output.txt > request_status.json
rwlgt-iiaaa-aaaaa-aaaaa-cai
is the ID of hello canister in the default project.
cat update.json | icx send
...
RequestID: 0x1234....
cat request_status.json | icx --fetch-root-key send
...
("Hello, everyone!")
When sending message to the IC main net, all --fech-root-key
are not required. So the sign step can be executed on an air-gapped machine.