区块链2.0以太坊环境搭建
Posted 尹成
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了区块链2.0以太坊环境搭建相关的知识,希望对你有一定的参考价值。
一下在ubuntu16.04版本下测试:
1、如果没有安装,需首先安装git
sudoapt-get git
sudoadd-apt-repository ppa:git-core/ppa
sudoapt-get update
sudoapt-get install git
查看版本号:
git --version
2、安装geth
sudo apt-get installsoftware-properties-common
sudo add-apt-repository-y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get installethereum
获取geth指令
geth --help
安装后,运行:
geth console
3、安装npm与nodejs
安装后,输入:
node -v
由于新版的nodejs已经集成了npm,所以之前npm也一并安装好了。同样可以通过输入 "npm-v" 来测试是否成功安装。命令如下,出现版本提示表示安装成功:
$ npm -v
2.3.0
4、solc安装
solidity是以太坊智能合约的开发语言。想要测试智能合约,开发DAPP的需要安装solc。官方文档获取更多信息
https://solidity.readthedocs.io/en/develop/installing-solidity.html
sudo add-apt-repositoryppa:ethereum/ethereum
sudo apt-get update
sudo apt-get installsolc
5、安装solc-cli
npm i solc-cli
备用:
sudo npm install -g solcsolc-cli –save-dev
6、安装testrpc
testrpc是在本地使用内存模拟的一个以太坊环境,对于开发调试特别方便快捷,当合约在testrpc中测试通过后,再部署到geth中去。
sudo npm install -g ethereumjs-testrpc
完成后输入测试:
testrpc
7、安装truffle
sudo npm install -g truffle
验证:
truffle version
错误:
如果你是直接执行
sudo npm -g install solc
sudo npm -g install solc-cli
或者
sudo npm -g install solc solc-cli --save-dev
那么就进坑了。。。就会出现下面这种情况
solc-cli@^0.3.0requires a peer of solc@^0.3.5 but none was installed.
突然想起了一个好办法,它说需要solc@^0.3.5的,那我指定安装这个版本的不就行了嘛,然后执行命令
sudo npm -g installsolc@^0.3.5 solc-cli --save-dev
错误2:
使用truffle init命令时出现如下错误,主要是nodejs安装问题
SyntaxError:Unexpected token =
atexports.runInThisContext (vm.js:53:16)
atModule._compile (module.js:374:25)
atObject.Module._extensions..js (module.js:417:10)
at Module.load(module.js:344:32)
atFunction.Module._load (module.js:301:12)
atFunction.Module.runMain (module.js:442:10)
atstartup (node.js:136:18)
atnode.js:966:3
在github上找到解决方法(https://github.com/trufflesuite/truffle/issues/128),把nodejs升级一下就可以了,这里我们通过安装n模块来升级
sudo npm install -g n
sudo n stable --
错误3:
npm遇到的问题:
I am going to update npm latest ver butit's showing this error message, help me to solve this problem thank you ..
G:>npm i -g npm ERR!code ENOLOCAL npm ERR! Could not install from "" as it does notcontain a package.json file.
npm ERR! A complete logof this run can be found in: npm ERR!
C:\\Users\\hemanth\\AppData\\Roaming\\npm-cache_logs\\2018-01-08T03_34_29_774Z-debug.log
解决方案:
npm cache verify
npm install -gcreate-react-app
错误4:
Error: Cannot find module'./build/Release/scrypt':解决办法:
https://blog.csdn.net/wo541075754/article/details/53155578
参考资料:
https://blog.csdn.net/little_stupid_child/article/details/79359809
https://blog.csdn.net/jeffrey__zhou/article/details/63695639
区块链开发(一)搭建基于以太坊go-ethereum的私有链环境
https://github.com/ethereum/go-ethereum
https://www.npmjs.com/package/solc
https://github.com/trufflesuite/truffle
https://github.com/ethereumjs/testrpc
网址:http://www.qukuailianxueyuan.io/
欲领取造币技术与全套虚拟机资料
区块链技术交流QQ群:756146052 备注:CSDN
尹成学院微信:备注:CSDN
以上是关于区块链2.0以太坊环境搭建的主要内容,如果未能解决你的问题,请参考以下文章