随着区块链技术的日益普及,越来越多的个人和小型团队开始探索如何在自己的设备上搭建区块链网络,树莓派作为一款价格低廉、功能强大的单板计算机,成为了搭建以太坊私链的理想选择,本文将详细介绍在树莓派上搭建以太坊私链的步骤,帮助初学者轻松入门。



pip包管理器。sudo apt update sudo apt install golang-go
git clone https://github.com/ethereum/go-ethereum cd go-ethereum
export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin
make geth
编译完成后,你将在build/bin目录下找到geth可执行文件。
mkdir -p ~/EthereumPrivateChainData
~/go-ethereum/build/bin/geth --datadir ~/EthereumPrivateChainData/ --port 30303 --http --http.addr 0.0.0.0 --http.port 8545 --networkid 15 mainnet
这将启动一个连接到主网的以太坊节点,但你可以省略mainnet参数来创建一个全新的区块链。
geth account new
geth的load命令将其部署到区块链上。geth attach ipc:~/EthereumPrivateChainData/geth.ipc --exec 'eth.compile.solidity(["YourContract.sol"])'
--eval 'eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[1],value:web3.toWei(1, "ether"),gas:2000000})'