Geth创建私有链

从官网复制最新的genesis.json文件

由于使用的教学视频的初始化文件在后期发起交易时,交易失败,交易一直处于pending状态,所以更换genesis.json文件。

{
    
    
  "config": {
    
    
    "chainId": 15,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0
  },
  "alloc": {
    
    
  # 官网没有在初始化分配账户余额,自定义添加了自己测试账户,并分配了以太币
	"0x8973eF760c378dfc84d6791C338d7DB288Ba2d2B":{
    
     "balance": "1000000000000000000"}
  },
  "coinbase": "0x0000000000000000000000000000000000000000",
  # 自己手动降低了难度
  "difficulty": "0x2000",
  "extraData": "",
  "gasLimit": "0x2fefd8",
  "nonce": "0x0000000000000042",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp": "0x00"
}
输入初始化命令后的结果
mao@ubuntu:~/Desktop/privateChain$ geth --datadir . init genesis.json 
INFO [12-19|16:01:07.279] Maximum peer count                       ETH=50 LES=0 total=50
INFO [12-19|16:01:07.279] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [12-19|16:01:07.280] Allocated cache and file handles         database=/home/mao/Desktop/privateChain/geth/chaindata cache=16.00MiB handles=16
INFO [12-19|16:01:07.300] Writing custom genesis block 
INFO [12-19|16:01:07.300] Persisted trie from memory database      nodes=1 size=148.00B time=87.304µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [12-19|16:01:07.301] Successfully wrote genesis state         database=chaindata hash=a1444f…ba3e08
INFO [12-19|16:01:07.301] Allocated cache and file handles         database=/home/mao/Desktop/privateChain/geth/lightchaindata cache=16.00MiB handles=16
INFO [12-19|16:01:07.304] Writing custom genesis block 
INFO [12-19|16:01:07.305] Persisted trie from memory database      nodes=1 size=148.00B time=64.703µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [12-19|16:01:07.305] Successfully wrote genesis state         database=lightchaindata hash=a1444f…ba3e08
启动私有链
mao@ubuntu:~/Desktop/privateChain$ geth --datadir . --networkid 15
WARN [12-19|16:20:04.266] Sanitizing cache to Go's GC limits       provided=1024 updated=992
INFO [12-19|16:20:04.267] Maximum peer count                       ETH=50 LES=0 total=50
INFO [12-19|16:20:04.268] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [12-19|16:20:04.269] Starting peer-to-peer node               instance=Geth/v1.9.3-stable-cfbb969d/linux-amd64/go1.15.6
INFO [12-19|16:20:04.269] Allocated trie memory caches             clean=248.00MiB dirty=248.00MiB
INFO [12-19|16:20:04.269] Allocated cache and file handles         database=/home/mao/Desktop/privateChain/geth/chaindata cache=496.00MiB handles=524288
INFO [12-19|16:20:04.301] Opened ancient database                  database=/home/mao/Desktop/privateChain/geth/chaindata/ancient
INFO [12-19|16:20:04.301] Initialised chain configuration          config="{ChainID: 15 Homestead: 0 DAO: <nil> DAOSupport: false EIP150: 0 EIP155: 0 EIP158: 0 Byzantium: 0 Constantinople: 0 Petersburg: 0 Istanbul: 0 Engine: unknown}"
INFO [12-19|16:20:04.301] Disk storage enabled for ethash caches   dir=/home/mao/Desktop/privateChain/geth/ethash count=3
INFO [12-19|16:20:04.301] Disk storage enabled for ethash DAGs     dir=/home/mao/.ethash count=2
INFO [12-19|16:20:04.301] Initialising Ethereum protocol           versions=[63] network=15 dbversion=<nil>
WARN [12-19|16:20:04.301] Upgrade blockchain database version      from=<nil> to=7
INFO [12-19|16:20:04.396] Loaded most recent local header          number=0 hash=a1444f…ba3e08 td=8192 age=51y8mo2w
INFO [12-19|16:20:04.396] Loaded most recent local full block      number=0 hash=a1444f…ba3e08 td=8192 age=51y8mo2w
INFO [12-19|16:20:04.396] Loaded most recent local fast block      number=0 hash=a1444f…ba3e08 td=8192 age=51y8mo2w
INFO [12-19|16:20:04.396] Regenerated local transaction journal    transactions=0 accounts=0
INFO [12-19|16:20:04.415] Allocated fast sync bloom                size=496.00MiB
INFO [12-19|16:20:04.422] Initialized fast sync bloom              items=1 errorrate=0.000 elapsed=5.761ms
INFO [12-19|16:20:04.435] New local node record                    seq=1 id=1dcc60834f758be7 ip=127.0.0.1 udp=30303 tcp=30303
INFO [12-19|16:20:04.436] Started P2P networking                   self=enode://c335248f511879dedf898186d0e38c508f9033d4096e76673cc3fcef06b9bf0bfe2ab2ba431058f1154341bf7cb6ba7cf2c317e35c4727029df638d577bdec5f@127.0.0.1:30303
INFO [12-19|16:20:04.438] IPC endpoint opened                      url=/home/mao/Desktop/privateChain/geth.ipc

猜你喜欢

转载自blog.csdn.net/mingrizhixin/article/details/111407625