1

I have a newly created private Ethereum "network". I have a question about my balance. In my genesis file, I have my account listed with a starting balance of 0x200000000000000000000000000000000000000000000000000000000000000 (the default value when you use puppeth) Even though I have mined many blocks, my balance isn't changing. I have been staring at this for a while now and don't know what else to look at.

The gist of what I've done:

  1. Install geth
  2. mkdir -p /data/miner0
  3. cd /data
  4. geth --datadir miner0/ account new
  5. (enter password, save password and account id)
  6. using puppeth, create genesis.json file (mine is named 5private.json) and I've chosen "Ethash - proof-of-work"
  7. initialize nodes geth --datadir miner0/ init 5private.json
  8. geth --datadir miner0/ --networkid 35195193 --syncmode 'full' --port 32519 --rpc --rpcaddr 'localhost' --rpcport 8502 --rpcapi 'admin,debug,web3,eth,txpool,personal,ethash,miner,net' --bootnodes 'enode://e2bfa2c1c3dbed66ca2f6787935ea0d6b7013057c9632189e7339c2a6cc2c0452b0d08784517652e0e4dd17044401549bbaef23faf0e16e87bf3d16f42a699f3@127.0.0.1:30519' --gasprice '1' -unlock '0xD4D34828d38A87BcAf376C03696582D6010E14D4' --password miner0/passwd.txt --mine --allow-insecure-unlock
  9. Connect to console geth attach miner0/geth.ipc
  10. Start miner miner.start(1)

My genesis file looks like:

{
  "config": {
    "chainId": 51933519,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "ethash": {}
  },
  "nonce": "0x0",
  "timestamp": "0x5ea26680",
  "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "gasLimit": "0x47b760",
  "difficulty": "0x80000",
  "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x0000000000000000000000000000000000000000",
  "alloc": {
    <...omitted...a ton of "precompile-addresses that were prefunded w/ 1 wei...>
    "213eff4c47c046b2ea39748ee57232062114074e": {
      "balance": "0x200000000000000000000000000000000000000000000000000000000000000"
    },
    "54f7bad5b53e43e884254b4d92af0f2d7988589f": {
      "balance": "0x200000000000000000000000000000000000000000000000000000000000000"
    }
  }
}

But after nearly 24 hours, my balance remains at the initial value - it is not changing even though I have been mining blocks.

> eth.getBlock(eth.blockNumber).miner
"0xdfdabe96077efd9d537623a60da946cffddf25e8"
> eth.getBalance("dFdaBE96077EFD9D537623A60dA946cfFDDf25e8")
9.04625697166532776746648320380374280103671755200316916267512375061821325312e+74
(this is the decimal value of the hex balance in genesis above)
> eth.accounts
["0xdfdabe96077efd9d537623a60da946cffddf25e8"]
> eth.blockNumber
6545
> eth.hashrate
45566
> eth.getBalance(eth.coinbase).toNumber();
9.046256971665328e+74
> eth.syncing
false

Any suggestions on what I need to look at?

1
  • 2
    I don't see any obvious error, it might be that your initial balance is too high, 9.046x10^56 ethers. Since last fork you get 2 ethers per block, so it will take a lot of time to see changes if you only display a few digits. If you show all digits in hex it should be obvious it has changed.
    – Ismael
    Apr 25, 2020 at 18:26

1 Answer 1

1

I started all over, following the brief, concise, yet effective instructions here: How to use a private network in geth? I have a single node mining and earning ether but I wasn't able to join a second node and am still trying to figure that one out. As the post indicates, these are the steps to get a miner going:

Create a genesis.json file:

{
  "config": {
    "chainId": 33551199,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0
  },
  "difficulty": "40",
  "gasLimit": "2100000",
  "alloc": {}
}

Create a first node and make sure it works:

$ mkdir node1
$ geth --datadir node1 account new
$ geth --datadir node1 account new
$ geth --datadir node1 init genesis.json
$ geth --datadir node1 --networkid 33551199 console
> miner.start(1)

This will get the first miner going and your balance will begin to increase as blocks are mined.

Be sure to also follow these instructions, specifically, pay attention to these flags:

--nodiscover

Use this to make sure that your node is not discoverable by people who do not manually add you. Otherwise, there is a chance that your node may be inadvertently added to a stranger’s blockchain if they have the same genesis file and network id.

--rpc

This will enable RPC interface on your node. This is generally enabled by default in Geth.

--rpcapi "db,eth,net,web3"

This dictates what APIs that are allowed to be accessed over RPC. By default, Geth enables the web3 interface over RPC.

IMPORTANT: Please note that offering an API over the RPC/IPC interface will give everyone access to the API who can access this interface (e.g. dapp’s). Be careful which API’s you enable. By default geth enables all API’s over the IPC interface and only the db,eth,net and web3 API’s over the RPC interface.

--rpcport "8080"

Change 8000 to any port that is open on your network. The default for geth is 8080.

--datadir "/home/TestChain1"

This is the data directory that your private chain data will be stored in (under the nubits . Choose a location that is separate from your public Ethereum chain folder.

--port "30303"

This is the “network listening port”, which you will use to connect with other peers manually.

--identity "TestnetMainNode"

This will set up an identity for your node so it can be identified more easily in a list of peers. Here is an example of how these identities show up on the network.

Launching geth

After you have created your custom genesis block JSON file and created a directory for your blockchain data, type the following command into your console that has access to geth:

geth --identity "MyNodeName" --rpc --rpcport "8080" --rpccorsdomain "*" --datadir "C:\chains\TestChain1" --port "30303" --nodiscover --rpcapi "db,eth,net,web3" --networkid 1999 init /path/to/CustomGenesis.json

Note: Please change the flags to match your custom settings.

This will initialize your genesis block. To interact with geth through the console enter:

geth --identity "MyNodeName" --rpc --rpcport "8080" --rpccorsdomain "*" --datadir "C:\chains\TestChain1" --port "30303" --nodiscover --rpcapi "db,eth,net,web3" --networkid 1999 console

You will need to start your geth instance with your custom chain command every time you want to access your custom chain. If you just type “geth” in your console, it will not remember all of the flags you have set.

The full list of methods available through the javascript console is available on the geth wiki on github

The command I am running for my node1 instance is:

geth --datadir node1/ --networkid 33551199 --nodiscover --rpc --rpcport "8533" --port "33333" --identity "EthereumMaster2" --rpcapi "admin,debug,miner,personal,eth,net,web3"

And my balance is increasing:

> eth.getBalance(eth.getBlock(eth.blockNumber).miner)
3.325e+21
> eth.getBalance(eth.getBlock(eth.blockNumber).miner)
4.265e+21
> eth.getBalance(eth.getBlock(eth.blockNumber).miner)
4.905e+21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.