达世币全节点


Eth全节点docker容器部署文档

<h1>Docker容器部署以太坊公有链</h1> <h2>相关文档</h2> <p><code>https://github.com/ethereum/go-ethereum/wiki/Running-in-Docker https://blog.csdn.net/ddffr/article/details/75250661 https://hub.docker.com/r/ethereum/client-go/ </code></p> <h3>docker安装</h3> <ul> <li>下载docker.dmg文件,然后点击,一步步操作(mac下)</li> <li>执行docker version,查看是否安装成功</li> </ul> <h2>操作流程</h2> <ol> <li>新建文件Dockerfile,以构建镜像</li> <li>使用命令:docker build -t eth_docker:dev ./,构建镜像</li> <li>执行docker images查看生成的镜像</li> <li>启动镜像: <pre><code> 全节点模式:docker run -it -p 8545:8545 -p 30303:30303 -v /Users/admin/Desktop/docker-build/eth_blockdata:/root/.ethereum eth_docker:test2 --rpc --rpcaddr "0.0.0.0" --rpcport 8545 --rpcapi="db,eth,net,web3,personal,web3"</code></pre></li> </ol> <pre><code></code></pre> <p>开发测试模式:docker run -it -p 8545:8545 -p 30303:30303 -v /Users/admin/Desktop/docker-build/eth_blockdata1:/root/.ethereum eth_docker:test2 --dev --rpc --rpcaddr &quot;0.0.0.0&quot; --rpcport 8545 --rpcapi=&quot;db,eth,net,web3,personal,web3&quot;</p> <pre><code>参数说明: * -p 8545:8545-映射端口 * --rpc --rpcaddr "0.0.0.0" --rpcport 8545 --rpcapi="db,eth,net,web3,personal,web3" 允许外部通过rpc连接,rpcaddr必须是0.0.0.0,不能是localhost或127.0.0.1,--rpcapi 允许外部客户端能执行的操作 * -v /Users/admin/Desktop/docker-build/eth_blockdata 指定挂载出来的区块数据存储目录,可自定义 * --dev:启动以太坊开发测试链,只有自身一个节点 5. 容器启动后,可执行docker exec -it 87fadc0249a9 /bin/bash #进入容器 6. 执行geth attach ipc:/root/.ethereum/geth.ipc(全节点)或者geth attach ipc:/tmp/geth.ipc(测试)进入geth交互模式 ## 代码连接示例(node.js) </code></pre> <p>const Web3 = require(&quot;web3&quot;); var web3 = new Web3(new Web3.providers.HttpProvider(&quot;<a href="http://localhost:8545">http://localhost:8545</a>&quot;)) //const web3 = new Web3(new Web3.providers.HttpProvider('<a href="https://rinkeby.infura.io/v3/8682ca3101ca48cbab091ef510b57aec'));(测试建议使用这个节点">https://rinkeby.infura.io/v3/8682ca3101ca48cbab091ef510b57aec'));(测试建议使用这个节点</a>) var address=&quot;0xca1c7fd3017d23f7702c1d7ee545884b665fda66&quot; web3.eth.getBalance(address, function (err, balance) {//查询余额 console.log(balance) }); var hash =&quot;0x73f78805165c1bb1e826bc2122bea98f7315f51f0e13d35aa68982d371d249a1&quot;; web3.eth.getTransaction(hash, function (err, result) {//查询交易详情 console.log(result); });</p> <pre><code></code></pre>

页面列表

ITEM_HTML