Eth101:以太坊开发环境部署(CentOS)

in #ethereum6 years ago

继比特币之后,以太坊提供了一个可以自己编写智能合约、发布Token的平台,需要的开发环境包括Nodejs、Truffle、Solidity等等,可以不熟悉,但是最好掌握一门程序语言(Javascript最好)。
工欲善其事,必先利其器。先了解一下如何部署开发环境。

  1. 事前准备:下载以太钱包,以太坊账户,充入一点以太币(如0.05)。
    6种以太钱包:http://ethfans.org/posts/584
    以太币交易网站:https://link.zhihu.com/?target=http%3A//www.123haody.com/ethtop(自定义)
    其他比如火币网,OKCoin,龙网,等等。(找时间都注册一下,获取推荐码)
    以下步骤2-?可参见:https://learnblockchain.cn/2017/11/24/init-env/

  2. 安装智能合约语言Solidity编译环境
    浏览器版:https://ethereum.github.io/browser-solidity
    自己安装:https://solidity.readthedocs.io/en/develop/installing-solidity.html

  3. 部署geth环境
    Go语言版:https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu
    运行:
    geth --datadir testNet --dev console 2>> test.log
    [root@localhost geth]# geth --datadir testNet --dev console 2>> test.log
    Welcome to the Geth JavaScript console!

  4. 编写合约代码,部署智能合约
    hello.sol
    将solidity编译好的web3代码,拷贝到geth控制台中,注意,如果出现:
    Error: authentication needed: password or unlock undefined
    表示需要解锁:personal.unlockAccount(eth.accounts[1],"account101");

  5. 在 CentOS7 中安装 Nodejs
    https://www.cnblogs.com/lpbottle/p/7733397.html
    如果gcc版本在4.8.5以下,需要升级:
    http://www.cnblogs.com/lpbottle/p/install_gcc.html(configure有错误,使用下面的链接)
    http://blog.csdn.net/zr1076311296/article/details/51334538

  6. 安装Truffle
    npm install truffle

  7. 安装测试环境Ganache-CLI(TestRPC)
    npm install -g ganache-cli

  8. 安装Web3.js
    npm install -g web3
    出现问题:119.jpg
    gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/6.13.0"
    gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/web3/node_modules/sha3/.node-gyp"

  9. 用一个实例pet-shop来开发dapp
    https://learnblockchain.cn/2018/01/12/first-dapp/
    过程见下面: Eth101:基于以太坊的智能合约应用示例:PET SHOP TUTORIAL (译)

Coin Marketplace

STEEM 0.28
TRX 0.12
JST 0.033
BTC 69747.29
ETH 3747.51
USDT 1.00
SBD 3.78