Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create multi-node transfer of ethernet private chain by Mac

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how Mac creates multi-node transfer of Ethernet private chain. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

1. Mac1 computer node

Create a genesis.json file

{

"config": {

"chainId": 898

"homesteadBlock": 0

"eip155Block": 0

"eip158Block": 0

}

"alloc": {

"0x2258b64ee6163edc94f1cd7c98de178adbc0a91c": {"balance":

"1000000000000000000000"}

"0x4c33529ed970f2dcd645beb91ae6bb985bd8c3c4": {"balance":

"1000000000000000000000"}

}

"coinbase": "0x0000000000000000000000000000000000000000"

"difficulty": "0x000000100"

"extraData":

"gasLimit": "0xffffffff"

"nonce": "0x0000000000000042"

"mixhash":

"0x0000000000000000000000000000000000000000000000000000000000000000"

"parentHash":

"0x0000000000000000000000000000000000000000000000000000000000000000"

"timestamp": "0x00"

}

$cd / Users/shijun/Desktop/blockChain/ethereum/private

$geth-datadir data0 init genesis.json

$geth-identity "itari"-datadir data0-networkid 898-port 30303-rpc-rpcaddr localhost-rpcport 8545-gcmode archive console

Note-the gcmode archive parameter is to save the amount on the hard disk.

> personal.newAccount ()

Passphrase:

Repeat passphrase:

"0x902dbef5c59c10e7e5744eee6aa622c455a05d79"

> personal.newAccount ()

Passphrase:

Repeat passphrase:

"0x764ad66588b7b3bf4ebd22ca55a419792e3b8456"

> admin.nodeInfo.enode

"enode://dcab3950426148473714e031ace294e0efb607bebb93d2a8312024cd44db48a8691125aa463e2fe2cd1eff2eeb7db86061803b212c3e3b5fed94001ef8c5a50f@ [:]: 30303"

> INFO [05-21 | 14:05:46] Block synchronisation started

The above is an automatic synchronization block, not a manual input.

> eth.blockNumber

forty-three

> eth.accounts

> eth.getBalance (eth.accounts [0])

Metamask operation

Select Local Network localhost 8545

Import the account json file into MetaMask

/ Users/shijun/Desktop/blockChain/ethereum/private/data0/keystore/UTC--2018-05-21T06-00-31.402671377Z--902dbef5c59c10e7e5744eee6aa622c455a05d79

And

/ Users/shijun/Desktop/blockChain/ethereum/private/data0/keystore/UTC--2018-05-21T06-00-51.372530256Z--764ad66588b7b3bf4ebd22ca55a419792e3b8456

II. Mac2 computer node

After the same steps as above, join the node

> admin.addPeer ("enode://619c5b62f9f25ba7e4dee1f7dd3e0cf9ac8a27e46503078df7c86f139f75e465c2818df7735b319c95b4b2d805f92e218d742fb25695987bb4a007d5062eb421@10.85.110.146:30303")

True

INFO [05-21 | 14:23:37] Block synchronisation started

> personal.newAccount ()

> eth.getBalance (eth.accounts [0])

> miner.start (1); admin.sleepBlocks (1); miner.stop ()

3. Mac1 computer node

Terminal operation

> amount=web3.toWei (1)

"100000000000000000000"

> personal.unlockAccount (personal.listAccounts [0])

Unlock account 0x902dbef5c59c10e7e5744eee6aa622c455a05d79

> eth.sendTransaction ({from:eth.accounts [0], to: "0x40b2b202b605efc69da3507c6072a66651dd09b5", value:amount})

INFO [05-21 | 14:31:00] Submitted transaction

> eth.getBalance (eth.accounts [0])

> miner.start (1); admin.sleepBlocks (1); miner.stop ()

True

Start the private chain again after shutdown

$cd / Users/shijun/Desktop/blockChain/ethereum/private

$geth-identity "itari"-datadir data0-networkid 899-port 30303-rpc-rpcaddr localhost-rpcport 8545-gcmode archive console

Note-the gcmode archive parameter is to save the amount on the hard disk.

Using this, local java projects can be connected.

Note: java calls the miner command to start the private chain using the following command

Non-back-end operation mode

Geth-- identity "itari"-- gcmode archive-- datadir data0-- networkid 898-- port 30303-- rpc-- rpcaddr localhost-- rpcport 8545-- rpcapi "db,web3,eth,personal,miner,net,txpool"-- rpccorsdomain "*" console 2 > > data.log

Note-the gcmode archive parameter is to save the amount on the hard disk.

Note: separate operation mode of front and rear

Nohup geth-- identity "itari"-- gcmode archive-- datadir data0-- networkid 898-- port 30303-rpc-- rpcaddr localhost-- rpcport 8545-- rpcapi "db,web3,eth,personal,miner,net,txpool"-- rpccorsdomain "*" &

Interactive command

$geth attach ipc:/usr/local/ethereum/private/data0/geth.ipc

Note: if the public network is accessed remotely, localhost is changed to 0.0.0.0

On how to create Mac ethernet private chain multi-node transfer to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report