wget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.3-991384a7.tar.gz
tar xvf geth-linux-amd64-1.10.3-991384a7.tar.gz
sudo mv geth-linux-amd64-1.10.3-991384a7/geth /usr/local/bin
geth -h
You see the geth help page,
as shown below.
Execute this command:
geth account new
You need to enter a passphrase twice.
For this project, I recommend using
P@ssw0rd
Obviously, if you get real Ether worth real money, you need to use a more secure passphrase.
You see a Public address, as shown below. This is your account's public key.
nano init.json
Paste in this code. Replace the address in the line
beginning with "alloc" with your own Address.
{
"config": {
"chainId": 10,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"ethash": {}
},
"nonce": "0x0",
"timestamp": "0x5e4a53b2",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x80000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"0x8535fe94e84541626e1B3cB95cEdf4E2d1FAdCDC": {
"balance": "0x2000000000000000000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
Save the file with Ctrl+X, Y, Enter.
geth init init.json
The program runs successfully, ending with
"Successfully wrote genesis state",
as shown below.
To start mining, execute this command:
geth --mine --nodiscover --maxpeers 0 --networkid 10 -rpc -rpccorsdomain "*" --miner.threads 4
Here's a description of those command-line
arguments, from
How to Build a Private Ethereum Blockchain
.
Geth starts, as shown below. It begins "Generating DAG". The DAG is a 1 GB file used for "proof of work", as explained here.
It took about 15 minutes to make the DAG when I did it on 11-20-21.
When the DAG is generated, it starts mining blocks, as shown below.
You won't actually earn rewards until you see the "block reached canonical chain" messages, as shown below.
Leave this window open.
Execute these commands to see the accounts in your blockchain.
sudo apt update
sudo apt install curl -y
curl -H "Content-Type: application/json" -X POST --data \
'{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' \
http://localhost:8545
There's only one account: the one you
created previously,
as shown below.
curl -H "Content-Type: application/json" -X POST --data \
'{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x8535fe94e84541626e1b3cb95cedf4e2d1fadcdc", "latest"],"id":1}' \
http://localhost:8545
Your balance appears, as a large hexadecimal value.
After a few seconds, repeat the command again. Your balance is increasing, as shown below, as you earn rewards for mining blocks.
C 340.1: eth_mining (10 pts)
Execute this command:The flag is covered by a green rectangle in the image below.
curl -H "Content-Type: application/json" -X POST \ --data '{"jsonrpc":"2.0","method":"eth_mining","params":[],"id":1}' \ http://localhost:8545