<img src="https://user-images.githubusercontent.com/1866848/50449130-2e4fc180-0960-11e9-8878-2fc1cb817593.jpg" width="300" align=center />
Windows下DApp开发攻略
由于有界面的本地链环境longclaw在windows下存在未解的兼容性问题,考虑到部分Windows用户的开发需求,
本文给出另外两种可行的开发方案
一、基于无界面的docker链环境开发
本地链环境依赖docker,下文以windows 10下docker安装为例,其它版本的windows请自行攻略
1、安装、配置并启动docker
-
下载docker: https://download.docker.com/win/stable/InstallDocker.msi
-
开启windows 10的Hyper-V:控制面板 - 程序 - 启用或关闭windows功能
<img src="https://user-images.githubusercontent.com/1866848/50449344-c0a49500-0961-11e9-98f2-c7ee7dd08600.png" width="300" align=center />
- 注意启动的时候可能会遇到内存不够的情况,需要找到右下角的鲸鱼图标右键 - 设置,修改VM的内存大小后Docker会重新启动
<img src="https://user-images.githubusercontent.com/1866848/50449387-11b48900-0962-11e9-885f-5f4334a42ae3.png" width="300" align=center />
- Docker Hub会比较慢,我们可能需要使用国内代理:https://registry.docker-cn.com. 并点击Apply
<img src="https://user-images.githubusercontent.com/1866848/50449475-9acbc000-0962-11e9-9a3b-2c0a35b15f2b.png" width="300" align=center />
2、下载镜像并构建链环境
-
git clone https://github.com/ultrain-os/u3.js.git
-
cd u3.js/docker
执行脚本start.bat
-
浏览器中访问http://127.0.0.1:8888/v1/chain/get_chain_info,出现以下界面说明环境构建成功
<img src="https://user-images.githubusercontent.com/1866848/50449562-23e2f700-0963-11e9-940d-6d120f2900c2.png" width="300" align=center />
- 使用默认创建的固定测试账号开发,账号名和公私钥在
u3.js/src/scratch
目录下面
<img src="https://user-images.githubusercontent.com/1866848/50449624-71f7fa80-0963-11e9-892e-8d102724fbcd.png" width="300" align=center />
二、连接远程测试网络进行开发
如果不想构建本地链环境,也可以直接基于远程测试网络进行开发
1、在浏览器https://explorer.ultrain.io/account-new或UltrainOneIOS版或Android版的钱包中创建一个测试账号,并保存好私钥与助记词
2、在浏览器中为你的账号申请资源https://developer.ultrain.io/resources
<img src="https://user-images.githubusercontent.com/1866848/50450097-94d7de00-0966-11e9-9eb1-3d45cce9ed93.png" width="300" align=center />
3、修改Robin产生的项目中config.js
配置信息
const config = {
httpEndpoint: 'http://benyasin.s1.natapp.cc',
httpEndpoint_history: 'http://history.natapp1.cc',
broadcast: true,
debug: false,
verbose: false,
sign: true,
logger: {
log: console.log,
error: console.error,
debug: console.log
},
chainId: '262ba309c51d91e8c13a7b4bb1b8d25906135317b09805f61fcdf4e044cd71e8',
keyProvider: '改为你申请的测试网账号的私钥',
binaryen: require('binaryen')
};
module.exports = config;
同时不要忘了修改migrate.js
中的账号为你申请的测试网账号名
三、本地进行合约或DApp开发
具体开发流程请使用Robin框架,参考上面几篇教程或以下几个示例: