Distribution de travail : Ubuntu 18.04 Liens : https://www.une-blockchain.fr/ethereum-creer-une-blockchain-privee/ https://blog.webnet.fr/implementation-blockchain-privee-geth/
util01@station01:~$ sudo apt-get update && sudo apt-get upgrade
util01@station01:~$ sudo add-apt-repository -y ppa:ethereum/ethereum util01@station01:~$ sudo apt-get install ethereum
util01@station01:~$ mkdir -p ETHEREUM/data util01@station01:~$ cd ETHEREUM/ util01@station01:~/ETHEREUM$
Créer :
~/ETHEREUM/genesis.json
Ajouter :
{ "nonce": "0x0000000000000042", "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", "difficulty": "0x20000", "alloc": {}, "coinbase": "0x0000000000000000000000000000000000000000", "timestamp": "0x0", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "extraData": "0x", "gasLimit": "0xffffffff", "config": { "chainId": 7789, "homesteadBlock": 0, "eip150Block": 0, "eip155Block": 0, "eip158Block": 0 } }
util01@station01:~/ETHEREUM$ geth --nousb --identity "hackcoin" --datadir "~/ETHEREUM/data" init genesis.json INFO [10-03|21:50:30.376] Maximum peer count ETH=50 LES=0 total=50 ... INFO [10-03|21:50:30.612] Successfully wrote genesis state database=lightchaindata hash="047862…906579"
util01@station01:~/ETHEREUM$ geth --datadir "~/ETHEREUM/data" --networkid 666 --http --http.port "8545" --http.corsdomain "*" --nodiscover --rpcapi="admin,eth,net,web3,personal,txpool,miner" --nousb --allow-insecure-unlock WARN [10-03|21:57:38.848] Sanitizing cache to Go's GC limits provided=1024 updated=664 ... INFO [10-03|21:57:39.054] HTTP server started endpoint=127.0.0.1:8545 cors=* vhosts=localhost
`util01@station01:~$ geth attach http://127.0.0.1:8545 Welcome to the Geth JavaScript console! instance: Geth/v1.9.22-stable-c71a7e26/linux-amd64/go1.15 at block: 0 (Thu Jan 01 1970 01:00:00 GMT+0100 (CET)) datadir: /home/util01/ETHEREUM/data modules: admin:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
`
> admin.nodeInfo
`> personal.newAccount() Passphrase: Repeat passphrase: "0x32aa8d0e0141e924e8e487c5863642128c3e0221"
`
> eth.accounts ["0x32aa8d0e0141e924e8e487c5863642128c3e0221"]
`> eth.getBalance("0x32aa8d0e0141e924e8e487c5863642128c3e0221")
eth.getBalance(eth.accounts[0]) web3.fromWei(eth.getBalance(eth.accounts[0]),"ether")`
> miner.setEtherbase(web3.eth.accounts[0]) true
> miner.start() null
Attendre quelques minutes.
`> miner.stop()
[sourcecode language="plain"]
eth.getBalance("0x32aa8d0e0141e924e8e487c5863642128c3e0221") 255000000000000000000 eth.getBalance(eth.coinbase) 290000000000000000000`
> miner.stop() null
personal.newAccount() Passphrase: Repeat passphrase: "0x05683a17c9fd8488e340da80a08400ba610963d5"
> eth.accounts ["0x32aa8d0e0141e924e8e487c5863642128c3e0221", "0x05683a17c9fd8488e340da80a08400ba610963d5"]
> eth.getBalance("0x05683a17c9fd8488e340da80a08400ba610963d5")
> personal.unlockAccount("0x32aa8d0e0141e924e8e487c5863642128c3e0221") Unlock account 0x32aa8d0e0141e924e8e487c5863642128c3e0221 Passphrase: true
`> eth.sendTransaction({from: "0x32aa8d0e0141e924e8e487c5863642128c3e0221", to: "0x05683a17c9fd8488e340da80a08400ba610963d5", value: web3.toWei(1, "ether")}) "0x75592128b8c19c1181b9fe713713ab4dcf18f56c5291c1f84a307334256b83fc"
`
> txpool.status { pending: 1, queued: 0 }
> miner.start() null
Attendre quelques minutes.
> txpool.status { pending: 0, queued: 0 }
> eth.getBalance("0x32aa8d0e0141e924e8e487c5863642128c3e0221") 739000000000000000000
> eth.getBalance("0x05683a17c9fd8488e340da80a08400ba610963d5") 1000000000000000000