美文网首页
搭建以太坊私链挖矿

搭建以太坊私链挖矿

作者: 子晔_ | 来源:发表于2020-11-20 16:09 被阅读0次

安装

brew tap ethereum/ethereum
brew install ethereum

初始化

mkdir ~/geth
cd geth
vim genesist.json

问题1
Fatal: Failed to write genesis block: unsupported fork ordering: eip150Block not enabled, but eip155Block enabled at 0

{
    "config": {
        "chainId": 666, 
        "homesteadBlock": 0, 
        "eip150Block": 0, 
        "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", 
        "eip155Block": 0, 
        "eip158Block": 0, 
        "byzantiumBlock": 0, 
        "constantinopleBlock": 0, 
        "petersburgBlock": 0, 
        "istanbulBlock": 0, 
        "ethash": { }
    }, 
    "nonce": "0x0", 
    "timestamp": "0x5ddf8f3e", 
    "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", 
    "gasLimit": "0x47b760", 
    "difficulty": "0x00002", 
    "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 
    "coinbase": "0x0000000000000000000000000000000000000000", 
    "alloc": {
        "0x1e82968C4624880FD1E8e818421841E6DB8D1Fa4": {
            "balance": "30000000000000000000"
        }
    }, 
    "number": "0x0", 
    "gasUsed": "0x0", 
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
geth --datadir ~/geth/data init ~/geth/genesist.json

问题2
Fatal: Failed to start the JavaScript console: api modules: Post "http://localhost:8545": dial tcp 127.0.0.1:8545: connect: connection refused

问题4
Error: account unlock with HTTP access is forbidden at web3.js

geth --datadir ~/geth/data --networkid 666 console --rpc --rpcport 8545 --rpcaddr 127.0.0.1 --rpc --rpcapi eth,web3,personal --allow-insecure-unlock  2>>~/geth/logs.txt

问题3
etherbase missing: etherbase must be explicitly specified

eth.accounts
miner.setEtherbase("0x......")
miner.getHashrate()
miner.stop()

转账

user1=eth.accounts[0]
user2=eth.accounts[1]
eth.sendTransaction({from: user1,to: user2,value: web3.toWei(3,"ether")})

Error: authentication needed: password or unlock

personal.unlockAccount('0xdb161745f122affbd2edd7f801d23c1968a3e18a','123456')

上面已经提示转帐成功了,但是user2帐户余额依然是0,是因为没有矿工来挖矿处理,我们启动一个矿工

新窗口连接

geth attach http://localhost:8545
eth.getBalance(eth.accounts[0])

参考:https://www.cnblogs.com/wanghui-garcia/p/10256520.html

相关文章

网友评论

      本文标题:搭建以太坊私链挖矿

      本文链接:https://www.haomeiwen.com/subject/hcadiktx.html