达世币全节点


以太坊全节点搭建

<pre><code>docker run -itd --net=host -v /disk_sc1/etc:/root/.etc herry143/etc:0.2 /etc/rc.local (13142)</code></pre> <p>什么是以太坊?</p> <ol> <li>以太坊(Ethereum)是一个建立在区块链技术之上, 去中心化应用平台。它允许任何人在平台中建立和使用通过区块链技术运行的去中心化应用、它被称为区块链2.0。</li> <li>可以将以太坊理解为区块链里的Android,它是一个开发平台,让我们就可以像基于Android Framework一样基于区块链技术写应用。</li> <li>在没有以太坊之前,写区块链应用是这样的:拷贝一份比特币代码,然后去改底层代码如加密算法,共识机制,网络协议等等(很多山寨币就是这样, 改改就出来一个新币)。</li> <li> <h2>以太坊平台对底层区块链技术进行了封装,让区块链应用开发者可以直接基于以太坊平台进行开发,开发者只要专注于应用本身的开发,从而大大降低了难度。</h2> <p>环境 golang NodeJs</p> </li> </ol> <hr /> <p>安装以太坊客户端geth</p> <ol> <li>以太坊钱包也就是我们的以太坊客户端、其实我们可以把它理解为一个开发者工具,它提供账户管理、挖矿、转账、智能合约的部署和执行等等功能</li> <li> <h2>钱包分两种 一种是交互式命令的控制台 就是我们上面所说的geth, 另一种是图形化钱包 以太坊有各种图形化钱包,包括电脑端和手机端的. sudo apt-get install software-properties-common sudo add-apt-repository -y ppa:ethereum/ethereum sudo apt-get update apt-get install ethereum sudo geth version 源码编译安装 git clone <a href="https://github.com/ethereum/go-ethereum">https://github.com/ethereum/go-ethereum</a> brew install go(需要go语言编译环境) cd go-ethereum make geth</h2> <p>同步全节点 测试链: 1.运行geth客户端,同步区块:</p> <pre><code>geth --rinkeby --datadir /data/eth_blockdata_testnet --rpc --rpcaddr "0.0.0.0" --rpcport 8545 --rpccorsdomain "*" --rpcapi="db,eth,net,web3,personal,web3" geth --syncmode fast --datadir /root/eth_blockdata --cache 2048 --rpc --rpcaddr "0.0.0.0" --rpcport 16666 --rpccorsdomain "*" --rpcapi="db,eth,net,web3,personal,web3"</code></pre> <p>(注:--rpc --rpcaddr &quot;0.0.0.0&quot; --rpcport 8545 允许外部通过rpc连接,rpcaddr必须是0.0.0.0,不能是localhost或127.0.0.1,--rpcapi=&quot;db,eth,net,web3,personal,web3&quot; 允许外部客户端能执行的操作) 2.连接节点,打开控制台:</p> <pre><code>geth attach ipc:/data/eth_blockdata_testnet/geth.ipc</code></pre> <p>主链:</p> <pre><code>1./data/go_code/go-ethereum/build/bin/geth --datadir /data/eth_blockdata --rpc 2.geth attach ipc:/data/eth_blockdata/geth.ipc</code></pre> <p>直接运行客户端即可开始同步区块。</p> </li> </ol> <p>geth --rpc 同步区块,并启用rpc服务,默认端口为8545 --datadir 指定区块数据存放目录 --dev 开发者模式 --testnet 使用测试网络 --rinkeby 使用rinkeby测试网络 --fast 快速同步模式,只同步BlockHeader,不同步BlockBody --cache 调整缓存大小,在4G内存时,geth频繁out of memory,建议--cache=512或更小</p> <hr /> <p>开发 可以直接调用geth的rpc进行开发,官方也封装了对应很多语言的库web3 这里使用web3js web3.js是一个库集合,允许您使用HTTP或IPC连接与本地或远程以太它节点进行交互。 geth --rpc npm install -g web3 var Web3 = require('web3'); var web3 = new Web3(new Web3.providers.HttpProvider(&quot;<a href="http://localhost:8545">http://localhost:8545</a>&quot;)); 更多细节可以阅读web3js文档</p>

页面列表

ITEM_HTML