终端1:
[root@swarm ICP]# sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"
[root@swarm ICP]# dfx new hello
[root@swarm ICP]# cd hello/
[root@swarm ICP]# dfx start
Cannot find dfx configuration file in the current working directory. Did you forget to create one?
[root@swarm ICP]# cd hello/
[root@swarm hello]# dfx start
Jul 03 07:25:11.705 INFO ic-starter. Configuration: ValidatedConfig { replica_path: Some("/root/.cache/dfinity/versions/0.7.2/replica"), replica_version: "0.8.0", log_level: Warning, cargo_bin: "cargo", cargo_opts: "", state_dir: "/home/ICP/hello/.dfx/state/replicated_state", http_listen_addr: V4(127.0.0.1:0), http_port_file: Some("/home/ICP/hello/.dfx/replica-configuration/replica-1.port"), metrics_addr: None, provisional_whitelist: Some(All), artifact_pool_dir: "/home/ICP/hello/.dfx/state/replicated_state/node-100/ic_consensus_pool", backup_config: None, crypto_root: "/home/ICP/hello/.dfx/state/replicated_state/node-100/crypto", state_manager_root: "/home/ICP/hello/.dfx/state/replicated_state/node-100/state", registry_local_store_path: "/home/ICP/hello/.dfx/state/replicated_state/ic_registry_local_store", unit_delay: None, initial_notary_delay: None, detect_consensus_starvation: None, consensus_pool_backend: Some("rocksdb"), state_dir_holder: None }, Application: starter
Jul 03 07:25:11.705 INFO Initialize replica configuration "/home/ICP/hello/.dfx/state/replicated_state/ic.json5", Application: starter
Jul 03 07:25:12.475 INFO Executing "/root/.cache/dfinity/versions/0.7.2/replica" "--replica-version" "0.8.0" "--config-file" "/home/ICP/hello/.dfx/state/replicated_state/ic.json5", Application: starter
Jul 03 07:25:15.108 WARN s:u7b5l-jah4e-mizss-s6cob-62ip7-ebcnz-ce7fs-z2s6l-7pou2-nvyoh-kqe/n:kz4x4-qiikp-wuwt5-axtwd-rrrv7-dzfqe-3tmqw-oscnf-7qtwl-f5gw3-7ae/ic_consensus/consensus starvation detected: RandomTapeMaker has not been invoked for 2.261762765s
Starting webserver for replica at "http://localhost:35439"
binding to: 127.0.0.1:8000
replica(s): http://localhost:35439/
终端2:
[root@swarm node_modules]# npm install
npm WARN @dfinity/agent@0.9.1-beta-1 requires a peer of @dfinity/candid@^0.9.1-beta-1 but none is installed. You must install peer dependencies yourself.
npm WARN @dfinity/agent@0.9.1-beta-1 requires a peer of @dfinity/principal@^0.9.1-beta-1 but none is installed. You must install peer dependencies yourself.
npm WARN hello_assets@0.1.0 No repository field.
npm WARN hello_assets@0.1.0 No license field.
audited 211 packages in 2.321s
57 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
[root@swarm node_modules]# npm install @dfinity/candid@^0.9.1-beta-1
npm WARN @dfinity/agent@0.9.1-beta-1 requires a peer of @dfinity/principal@^0.9.1-beta-1 but none is installed. You must install peer dependencies yourself.
npm WARN hello_assets@0.1.0 No repository field.
npm WARN hello_assets@0.1.0 No license field.
+ @dfinity/candid@0.9.1
added 1 package from 1 contributor and audited 212 packages in 1.843s
57 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
[root@swarm node_modules]# npm install @dfinity/principal@^0.9.1-beta-1
npm WARN hello_assets@0.1.0 No repository field.
npm WARN hello_assets@0.1.0 No license field.
+ @dfinity/principal@0.9.1
added 1 package from 1 contributor and audited 213 packages in 1.778s
57 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
[root@swarm node_modules]# dfx deploy
Deploying all canisters.
Creating canisters...
Creating canister "hello"...
"hello" canister created with canister id: "r7inp-6aaaa-aaaaa-aaabq-cai"
Creating canister "hello_assets"...
"hello_assets" canister created with canister id: "rkp4c-7iaaa-aaaaa-aaaca-cai"
Building canisters...
Building frontend...
Source path "src/hello_assets/assets" does not exist.
Source path "dist/hello_assets/" does not exist.
Installing canisters...
Creating UI canister on the local network.
The UI canister on the "local" network is "rno2w-sqaaa-aaaaa-aaacq-cai"
Installing code for canister hello, with canister_id r7inp-6aaaa-aaaaa-aaabq-cai
Installing code for canister hello_assets, with canister_id rkp4c-7iaaa-aaaaa-aaaca-cai
Authorizing our identity (default) to the asset canister...
Uploading assets to asset canister...
Deployed canisters.
[root@swarm node_modules]# dfx canister call hello greet everyone
("Hello, everyone!")
[root@swarm hello]# dfx canister call hello greet jacob
("Hello, jacob!")
# 查看 canister id
[root@swarm hello]# dfx canister id hello
rrkah-fqaaa-aaaaa-aaaaq-cai
# 停止 ICP 网络
dfx stop