美文网首页区块链研习社金马带你定投区块链
google cloud 搭建 ethereum测试环境(一)

google cloud 搭建 ethereum测试环境(一)

作者: eversterd | 来源:发表于2018-03-10 23:07 被阅读42次

google cloud 为新用户提供一年免费使用体验,http://cloud.google.com , 拿来搭建一些服务效果很好,教程参照 http://godjose.com/2017/06/14/new-article/

在计算引擎中搭建 ethereum 测试环境

1.安装geth

  sudo apt-get install software-properties-common
  sudo add-apt-repository -y ppa:ethereum/ethereum
  sudo apt-get update
  sudo apt-get install ethereum

2.solc安装 官方文档

  sudo add-apt-repository ppa:ethereum/ethereum
  sudo apt-get update
  sudo apt-get install solc
  1. 安装npm,官方网址

下载源码node-v6.9.4.tar.gz

  >tar xvf node-v6.9.4.tar.gz
  >cd node-v6.9.4
  >./configure
  >make
  >make install
  >node -v
  v6.9.4
  >npm -v
  3.10.10

4.安装 truffle和testrpc ,以太坊测试环境

  npm install -g truffle
  npm install -g ethereumjs-testrpc

现在安装会提示使用新一代框架 ganache-cli, 基于testrpc的一个测试环境

npm install -g ganache-cli

5.打开测试环境

>ganache-cli
运行ganache-cli

测试环境会默认产生10个地址,每个地址默认有100eth

  1. 搭建一个Dapp , truffle 有一个官方教程 ETHEREUM PET SHOP , 一步一步在本地搭建Dapp。

truffle unbox pet-shop

下载到本地后按教程内步骤就可以, 完成后的工程已经上传到github , 在google cloud上把工程文件克隆下来 ,可以直接编译智能合约

>truffle compile
编译合约

编译完成将合约部署到ethereum测试网络

>truffle migrate
部署合约

最后运行web工程,事先要把 ethereum测试网络的端口配置正确。

npm run dev


运行web

事先已经配置了google cloud 的外部ip地址,可以通过ip地址直接访问查看效果

   http://35.229.154.227:3000/
实际效果

下一篇将使用 以太坊 进行领养宠物

相关文章

网友评论

    本文标题:google cloud 搭建 ethereum测试环境(一)

    本文链接:https://www.haomeiwen.com/subject/gkapfftx.html