前言
作者简介:
yihuang:每日币经特约专家,前腾讯区块链专家,在游戏领域有多年一线开发经验,拥有自己个人专属的区块链游戏引擎,可在移动设备上实现源生APP,H5,3D落地。
编译运行Cardano钱包后端
Windows和Mac系统,直接使用官方发布的钱包安装包即可。
Linux系统需要自己编译,编译过程如下:
安装nix,在非root账户下运行:
$ curlhttps://nixos.org/nix/install| sh
运行后会自动配置当前环境,重新登录当前终端即可生效。
配置IOHK的Binary Cache:
$ sudo mkdir -p /etc/nix
$ sudo vi /etc/nix/nix.conf # ..or any other editor, if you prefer
添加:
binary-caches =https://cache.nixos.orghttps://hydra.iohk.io
binary-cache-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
取cardano源代码:
$ git clonehttps://github.com/input-output-hk/cardano-sl.git
$ cd cardano-sl
$ git checkout -b release/1.2.0 origin/release/1.2.0
编译:
$ nix-env -A cardano-sl-wallet-new --install --file .
因为有Binary Cache,应该很快,成功后在目录中会多一个的可执行文件,这个目录在安装nix的时候已经加入到了。
另外整一个运行的目录,把相关配置拷贝过来:
$ mkdir ~/cardano-wallet
$ cd ~/cardano-wallet
$ mkdir lib
$ cp /path/to/cardano-sl/lib/ lib
$ mkdir scripts
$ cp -r /path/to/cardano-sl/scripts/tls-files scripts/
创建文件,内容如下:
wallet:
fallbacks: 7
valency: 1
relays:
- - host:http://relays.cardano-mainnet.iohk.io
运行:
$ cardano-node --topology wallet-topology.yaml --configuration-key mainnet_wallet_linux64
验证钱包V1 API工作正常:
$ curl --cacert scripts/tls-files/ca.crt https://localhost:8090/api/v1/node-info
{"data":{"syncProgress":{"quantity":92,"unit":"percent"},"blockchainHeight":{"quantity":1072633,"unit":"blocks"},"localBlockchainHeight":{"quantity":996101,"unit":"blocks"},"localTimeInformation":{"differenceFromNtpServer":{"quantity":-147487,"unit":"microseconds"}}},"status":"success","meta":{"pagination":{"totalPages":1,"page":1,"perPage":1,"totalEntries":1}}}
使用V1 API实现充提
Cardano钱包API是符合swagger规范的,使用任何语言对swagger的封装即可使用,这里提供一个使用python的pyswagger的示例:http://t.cn/R1agokw。
【声明:文章已获作者本人授权,转载请联系我们】
应作者要求,在此分享其知乎专栏地址:
http://dwz.cn/7zdgWZ
(知乎APP内搜索“函数式编程与区块链”)
领取 专属20元代金券
Get大咖技术交流圈