---
title: "EthBox以太坊开发套件，一键安装部署以太坊开发环境"
author: "it_node"
date: "2018-06-07T17:30:41Z"
tags: []
categories: ["编程语言"]
slug: "ethbox"
draft: false
lastmod: "2018-06-07T17:38:29Z"
id: 2424523
url: "https://it-node.iteye.com/blog/2424523"
---

`EthBox`是汇智网为了方便以太坊开发学习者快速安装本地开发环境而制作的开发套件，可以一键安装以下必备开发工具：

- nodejs：8.11.2
- git：2.17.1.2
- geth：1.8.10
- ganache-cli：6.1.0
- truffle：4.1.11

`EthBox`即支持采用仿真器进行快速开发验证，也支持使用标准  
节点软件搭建私链测试，或接入公链进行部署。

`EthBox`的当前版本是0.0.1，目前仅适用于windows操作系统。

- - [EthBox下载地址 - 百度云盘](https://pan.baidu.com/s/1sjqciE0CsAHj2Qnm5f51KA)
  - [EthBox使用说明](http://blog.hubwiz.com/2018/06/07/ethbox-readme/)
  - [以太坊教程](http://xc.hubwiz.com/course/5a952991adb3847553d205d1)
  - [以太坊电商实战教程](http://xc.hubwiz.com/course/5abbb7acc02e6b6a59171dd6)

## 安装

执行下载到本地的`ethbox-setup.exe`启动安装程序：

![agreement](https://upload-images.jianshu.io/upload_images/11831773-2593db28bf4f87ee.png?imageMogr2%2Fauto-orient%2Fstrip%7CimageView2%2F2%2Fw%2F1240)

agreement

点击\[接受]按钮，进入安装目录选择：

![installdir](https://upload-images.jianshu.io/upload_images/11831773-36ba6137710e0aca.png?imageMogr2%2Fauto-orient%2Fstrip%7CimageView2%2F2%2Fw%2F1240)

installdir

点击\[安装]按钮，开始执行安装过程：

![install](https://upload-images.jianshu.io/upload_images/11831773-55e124f4a398f95b.png?imageMogr2%2Fauto-orient%2Fstrip%7CimageView2%2F2%2Fw%2F1240)

install

 安装完毕后，在桌面可以看到EthBox图标：

![shortcut](https://upload-images.jianshu.io/upload_images/11831773-d2aa396f9de84244.png?imageMogr2%2Fauto-orient%2Fstrip%7CimageView2%2F2%2Fw%2F1240)

shortcut

 

 

 

## 启动仿真器

点击桌面的EthBox图标，即可进入EthBox环境：

 

![EthBox](https://upload-images.jianshu.io/upload_images/11831773-5c2a695472c2f2df.png?imageMogr2%2Fauto-orient%2Fstrip%7CimageView2%2F2%2Fw%2F1240)

EthBox

执行`ganache-cli`启动仿真器：

 

```
C:\Users\user> ganache-cli
```

 

显示如下结果，表示成功启动：

![ganache](https://upload-images.jianshu.io/upload_images/11831773-a99facdd013705b8.png?imageMogr2%2Fauto-orient%2Fstrip%7CimageView2%2F2%2Fw%2F1240)

ganache

## 创建truffle项目

再次点击桌面的EthBox图标，进入EthBox环境。

创建一个项目目录，然后执行`truffle unbox webpack`初始化项目文件：

```
C:\Users\user> md demo
C:\Users\hubwiz\demo> truffle.cmd unbox webpack
```

 

你将会看到如下结果：

![truffle unbox webpack](https://upload-images.jianshu.io/upload_images/11831773-10d4778db30e60f1.png?imageMogr2%2Fauto-orient%2Fstrip%7CimageView2%2F2%2Fw%2F1240)

truffle unbox webpack

在`Setting up...`处将需要等待一会儿，因为需要从网络下载项目依赖包。

## 运行truffle项目

首先修改默认的`truffle.js`配置文件，将节点端口修改为8545 - 因为ganache-cli的监听端口是8545：

```
module.exports = {
  networks:{
    development: {
      port: 8545
    }
  }
}
```

 

然后修改`app/javascripts/app.js`中的节点URL，同样将端口修改为8545：

```
window.web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
```

 

现在执行`truffle compile`命令编译合约：

 

```
C:\Users\user\demo> truffle.cmd compile
```

 

 

编译过程中有一些警告，暂时忽略即可。

然后执行`truffle migrate`部署合约：

 

```
C:\Users\user\demo> truffle.cmd migrate
```

 

 

结果如下：

![truffle migrate](https://upload-images.jianshu.io/upload_images/11831773-5d0c3ecb34289f72.png?imageMogr2%2Fauto-orient%2Fstrip%7CimageView2%2F2%2Fw%2F1240)

truffle migrate

在部署过程中，如果你切换到ganache那个窗口，会看到一些交易信息 —— 部署合约也是一种交易：

![ganache transactions](https://upload-images.jianshu.io/upload_images/11831773-f211650dc0f61e4e.png?imageMogr2%2Fauto-orient%2Fstrip%7CimageView2%2F2%2Fw%2F1240)

ganache transactions

一切就绪！可以启动web服务器了：

 

```
C:\Users\user\demo> npm run dev
```

 

 

这个命令会执行内存打包并且启动一个在8080端口监听的web服务器：

![npm-run-dev](https://upload-images.jianshu.io/upload_images/11831773-d2dc21ec85087bc4.png?imageMogr2%2Fauto-orient%2Fstrip%7CimageView2%2F2%2Fw%2F1240)

npm-run-dev

现在，访问 [http://localhost:8080](http://localhost:8080/) 即可！

![web](https://upload-images.jianshu.io/upload_images/11831773-16e1a2a7f5432e25.png?imageMogr2%2Fauto-orient%2Fstrip%7CimageView2%2F2%2Fw%2F1240)

web

注意这句话：

> You have 10000 META

这个`10000`是从链上（ganache-cli）取来的，因此看到这个数字，就意味着，你的以太坊开发环境部署成功！

原文：[http://blog.hubwiz.com/2018/06/07/ethbox-readme/](http://blog.hubwiz.com/2018/06/07/ethbox-readme/)