使用 Nix 编译和运行 cardano-sl 并连接主网

我使用的环境是 Ubuntu 16.04.3 LTS,参考了以下来源:

  1. 克隆项目

    git clone https://github.com/input-output-hk/cardano-sl.git
    cd cardano-sl
    git checkout master
    
  2. 安装 Nix

    curl https://nixos.org/nix/install | sh
    
  3. 让 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=
    
  4. 使用 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
      
  5. 在连接主网前,建议使用 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
    
  6. 连接主网需要一段时间,期间可随时查看进程运行的情况和最新日志

    sudo systemctl status cardano-sl
    sudo journalctl -r -u cardano-sl
    
  7. 测试 Cardano SL Wallet Web API

    curl -k https://localhost:8090/api/settings/sync/progress
    

    如果有响应,说明 cardano-sl 正在运行

4 Likes

很不错啊,我也来试试。

话说,在mac下能编译吗?我试了一下失败了,是不是只能在linux上。

刚刚试着跑了下,没有问题。

macOS Version: 10.13.3

哪一步出错了?Log 可以发上来看看。

噢,运行起来了?看来是我搞错了,再试一下。

curl -k -X POST https://localhost:8090/api/v1/wallets
-H “Content-Type: application/json; charset=utf-8”
-H “Accept: application/json; charset=utf-8”
–cacert ./scripts/tls-files/ca.crt
-d ‘{
“operation”: “create”,
“backupPhrase”: [“squirrel”, “material”, “silly”, “twice”, “direct”,
“slush”, “pistol”, “razor”, “become”, “junk”, “kingdom”, “flee”],
“assuranceLevel”: “normal”,
“name”: “FirstWallet”
}’

之后没有返回结果 有没有人碰到

API v1-beta 可能还没合并入 master 吧

应该是合进入,有相关代码

部署成功了,可是部署完了可以做什么啊,又没有api?

目前 connect-to-mainnet 这个 script 好像还是默认使用 V0。

相关 Issue:https://github.com/input-output-hk/cardano-sl/issues/2719

更新:目前 master 分支在使用 API V1

相关 Issue:https://github.com/input-output-hk/cardano-sl/issues/2719

如何修改启动时候的监听地址.

目前监听都是 localhost, 我有从外部调用 api 的需求

我不太清楚在哪修改配置

可以试试 nginx reverse proxy

嗯,谢谢,今早已经用nginx反向代理搞定了

1 Like

如何获得测试网络的币?

第四步时报错,error: attribute ‘mainnetWallet’ in selection path ‘connectScripts.mainnetWallet’ not found
这是什么原因

同问我也遇到了类似的问题

localhost的https如何配置??

请问您呢边的localhost的https是如何配置的,望指教

大佬,在Linux机器上安装nix时报错,error: the group ‘nixbld’ specified in ‘build-users-group’ does not exist,怎么破啊