开发软件(操作均在dfx.json所在目录):
1.连上 IC-network (本地运行IC服务 其实是一个replica副本):
dfx start || dfx start --clean
(dfx start --clean命令启动 : 以clean状态启动 会清理掉在后台运行的可能会影响到操作的进程 比如: 其他IC网络)
2.在项目根目录(包含dfx.json的那个文件夹)创建罐 :
dfx canister create --all
3.在罐中构建(编译)代码:
dfx build || dfx build --check
4.在罐中部署代码:
dfx canister install actore_hello(project_name)
5.在命令行中余代码进行交互:
dfx canister call:
eg : dfx canister call project_name(location_hello) function_name(location) params(requird function params)
EG :
root@x:/home/x/dfinity /location_hello dfx canister call location_hello location "zhengzhou "
("Hello, zhengzhou !")
6.在浏览器中访问交互:
在dfx.json中 network部分有Ip与对应端口号 访问时在browser(浏览器)中输入 127.0.0.1:8000(IP+port)/candid?candid?canisterId=你的main.mo文件对应的canisterID 即可访问
例:
http://127.0.0.1:8000/candid?canisterId=rwlgt-iiaaa-aaaaa-aaaaa-cai
7.停止IC网络:
dfx stop
8.修改dfx.json: 增加多个actor
在 “canister” 下加入如下格式:
"actore_name" : {
"main" : "src/actor_name/main.mo",
"type" : "motoko"
},