安装 Plutus Playground (MacOS)

Cardano 目前还没有上线,测试网也还没开放(2021年6月)。 当前可以用来测试和练习的工具主要是 Plutus Playground。 虽然没有 Playground 也可以运行测试,但 Playground 还是很方便的。

Cardano 官方 IOHK 提供在线版本,也可以试用看看,但速度很慢,而且据说版本较旧,还是建议下载并安装本地版本。 在线版 URL 是:

https://playground.plutus.iohkdev.io/

我们开始安装。 这里的步骤主要参考

https://www.reddit.com/r/cardano/comments/mmzut6/macos_plutus_playground_build_instructions/

我在我的MacBook Pro 2019 macOS Big Sur 11.5 beta 上安装成功。

1 – 安装Nix

[$] sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume
 

2 - 关闭并重启Terminal (确保所有环境变量分配成功)

3 - 检查 Nix版本(可做可不做)

[$] nix --version

4 – 创建 /etc/nix/nix.conf

[$] nano /etc/nix/nix.conf

5 - 将这两行加入 nix.conf 文件里:

substituters = https://hydra.iohk.io https://iohk.cachix.org https://cache.nixos.org/
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=

*注意:* 这两行是要避免生成时间太久(其实这两行是强迫使用 IOHK 版本而不是最新版。 没有这两行会失败,浪费我很多时间)

***注意:***要检查 /etc/nix 和 /etc/nix/nix.conf 是否已存在。 如果没有要用

[$] mkdir /etc/nix
[$] touch /etc/nix/nix.conf

6 - 重启计算机

7 – 使用 git 下载 plutus

[$] git clone https://github.com/input-output-hk/plutus.git

8 – 以下命令要在 plutus 目录下运行

[$] cd plutus

9 – 生成Plutus Core 这个步骤很花时间,可能要几个小时

[$] nix build -f default.nix plutus.haskell.packages.plutus-core.components.library

*注意:*

有些MacOS BigSur 的用户报告以下的错误:

error: while setting up the build environment: getting attributes of path '/usr/lib/libSystem.B.dylib': No such file or directory

要解决这问题必须将 nix 改为 unstable 版本的 nixpkgs

[$] sudo nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable

*注意:*

如果出现以下错误:

"error: refusing to create Nix store volume ... boot volume is FileVault encrypted"

必须参考以下这两篇:

https://github.com/digitallyinduced/ihp/issues/93#issuecomment-766332648

https://www.philipp.haussleiter.de/2020/04/fixing-nix-setup-on-macos-catalina/

10 – 生成Plutus Playground Client / Server

[$] nix-build -A plutus-playground.client[$] nix-build -A plutus-playground.server

11 – 生成Plutus Playground 其它部分

[$] nix-build -A plutus-playground.generate-purescript
[$] nix-build -A plutus-playground.start-backend
[$] nix-build -A plutus-pab

12 – 启动nix-shell,这个步骤也可能花很多时间

[$] nix-shell

13 – 进入到 nix-shell 之后

[nix-shell] cd plutus-pab
[nix-shell] plutus-pab-generate-purs
[nix-shell] cd .. /plutus-playground-server
[nix-shell] plutus-playground-generate-purs

14 – 启动playground server

[nix-shell] plutus-playground-server

Server 端成功

15 – 打开新的terminal:

[nix-shell] cd plutus
[nix-shell] nix-shell
[nix-shell] cd plutus-playground-client

16 – 启动 playground client

[nix-shell] npm run start

这样就成功了!

打开浏览器,如果有安全警告忽略:

https://localhost:8009/

如果 localhost 无法使用,试试

https://127.0.0.1:8009

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值