Centos 下 Dfinity 公链网络部署

本文详细介绍了如何在Centos操作系统环境下部署Dfinity公链网络,通过两个终端的操作步骤,涵盖了从配置到启动的全过程,帮助读者理解并实践区块链技术的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-P9NAuOyv-1625300782740)(C:\Users\85380\AppData\Roaming\Typora\typora-user-images\image-20210703154213517.png)]

终端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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值