我使用的环境是 Ubuntu 16.04.3 LTS,参考了以下来源:
- https://github.com/input-output-hk/cardano-sl/blob/master/docs/how-to/build-cardano-sl-and-daedalus-from-source-code.md
- https://github.com/input-output-hk/cardano-sl/blob/master/docs/how-to/connect-to-cluster.md
-
克隆项目
git clone https://github.com/input-output-hk/cardano-sl.git cd cardano-sl git checkout master
-
安装 Nix
curl https://nixos.org/nix/install | sh
-
让 Nix 使用 IOHK 源
sudo mkdir -p /etc/nix sudo vi /etc/nix/nix.conf
将下面两行加入到 nix.conf 中
binary-caches = https://cache.nixos.org https://hydra.iohk.io binary-cache-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
-
使用 Nix 编译连接钱包主网所需要的 Cardano 组件
nix-build -A connectScripts.mainnetWallet -o connect-to-mainnet
如需连接其他网络:
-
Explorer 主网
nix-build -A connectScripts.mainnetExplorer -o connect-explorer-to-mainnet
-
钱包测试网络
nix-build -A connectScripts.stagingWallet -o connect-to-staging
-
Explorer 测试网络
nix-build -A connectScripts.stagingExplorer -o connect-explorer-to-staging
-
-
在连接主网前,建议使用 systemctl 来管理进程(如果想要直接运行:
./connect-to-mainnet
即可)sudo vi /etc/systemd/system/cardano-sl.service
写入
After=network.target [Service] ExecStart=/你的路径/cardano-sl/connect-to-mainnet Restart=always [Install] WantedBy=multi-user.target
如需连接其他网络,记得将 ExecStart 替换为:
-
Explorer 主网
ExecStart=/你的路径/cardano-sl/connect-explorer-to-mainnet
-
钱包测试网络
ExecStart=/你的路径/cardano-sl/connect-to-staging
-
Explorer 测试网络
ExecStart=/你的路径/cardano-sl/connect-explorer-to-staging
启动 cardano-sl.service 并连接主网
sudo systemctl enable cardano-sl.service sudo systemctl start cardano-sl.service
-
-
连接主网需要一段时间,期间可随时查看进程运行的情况和最新日志
sudo systemctl status cardano-sl sudo journalctl -r -u cardano-sl
-
测试 Cardano SL Wallet Web API
curl -k https://localhost:8090/api/settings/sync/progress
如果有响应,说明 cardano-sl 正在运行