You identify a block with either blockHash
, which is the hash of the block, or blockNumber
, which is the position of the block in the chain. Blocks can contain multiple transactions and are generated even if there are no transactions in them, so they should not be expected to increase in series with your transactions. blockNumber
is sometimes referred to as "height". Watch the console or log output of a node if you want to see blocks getting generated.
You can get block information with eth.getBlock()
. Pass it a block hash or block number.
You can get transaction information with eth.getTransaction()
. Pass it the transaction hash of the transaction you are interested in.
eth.getTransactionReceipt()
also expects a transaction hash.
You don't need root
for any of the purposes you mention, but if you're curious what it is, see: What is the 'root' of a transaction receipt?
I think it's mostly a nomenclature debate. I think the Bitcoin wiki sums it up pretty well (and it's the same case with Ethereum, at least in terms of naming):
A genesis block is the first block of a block chain. Modern versions
of Bitcoin (or Ethereum) number it as block 0, though very early versions counted it
as block 1. The genesis block is almost always hardcoded into the
software of the applications that utilize its block chain. It is a
special case in that it does not reference a previous block...
Now to your questions:
Like, if I fire up a few nodes and transfer some testETH between them, is that exchange the "genesis block"?
No, as soon as you 'transfer', it's not a part of the genesis block anymore.
Is it simply the first transaction I manually engage in?
Technically, it (genesis block) is the block referred to by the first transaction(s) you make (which will, of course, happen in the first block).
I assume it has to get mined like any other, yes?
No, it is not mined. It is essentially the 'system', or more precisely, the EVM state as soon as a node with a new chain (or a copy of a new chain) starts with. The mining will happen from then on, and most likely, other transactions will refer back to it (as in your case of sending testEth.)
I have to ask this because the block does not seem to automatically happen if there are no transactions.
This is interesting. Did you try checking from the console the current block height? I suspect there might be an issue with your explorer. Otherwise, it seems very much a specific configuration of your test node. Because, there doesn't have to be a transaction for a new block to be mined. The miner(s) will keep mining to meet the new block mine interval time criteria. I run a test node with Geth, and the blocks are mined irrespective of the transactions being there or not; this is basically what a miner is supposed to do and is the ideal behavior of a miner.
UPDATES: More details/ rationale on why the genesis block is not mined.:
The essential definition of mining in the context of the Ethereum network is two fold:
Processing and validating the transactions (also including the smart contracts)
Mining the block for consensus using proof-of-work/ ethash.
Now the genesis.json file, as I previously answered, sets the state of the node. There are no actual transactions, and hence no mining. There is nothing actually being transferred in the description of genesis.json, it is a mere description of wallets.
The question of the gasLimit
limit field is just an initial point of reference to start with. It might (and it does) change as per the behavior of the network participants in the Ethereum mainnet. In case of private chains, you would tweak it as per your needs. But it has nothing to do with the 'mining of the genesis block'. Even if you set it very low, say something that would allow only five transactions, and put hundred addresses and their corresponding balances in genesis.json, the genesis block would flow as smoothly as any gas (sorry for the bad pun).
I rely on the yellow paper for my source of definitions.
Best Answer
If you carefully look at how a blockchain works, this is something important to assure the integrity of the blockchin data. Normally a blockchain protocol works in a way to keep the block rate constant, in order to make it difficult to create a another chain which is longer. In ethereum a block is generated nearly every 14 seconds, and the difficulty is what keeps the average blockrate at that rate. You may refer this answer.
So whether there are transactions or not, miner s keep mining blocks and that's how the protocol is defined for a public network and since you are using the same protocol in your private chain (default geth client), In your private chain also its the same. The code @StevenJaxon had linked can be used to alter your private chain but then it would not be simulating the public chain anyhow for testing purposes that won't matter and it will save your computing power as well.
This pretty straight forward if you refer the web3 API reference here and here,
If what you want to do this inside a smart contract, you only be able to get the previous block number, and you can use the following code, refer this question.