How is it different than networkID?
ChainID was introduced in EIP-155 to prevent replay attacks between the main ETH and ETC chains, which both have a networkID of 1
.
It's basically just an additional way to tell chains apart. Subsequent to EIP-155, ETH has a chainID of 1
, while ETC has a chainID of 61
(even though they still have the same networkID of 1
).
Is chainID and networkID needed in every block or just the genesis block?
It's required for the chain to operate in general - e.g. it's required when signing transactions, meaning transactions signed on the ETH network end up with a different hash than those signed on ETC. Before EIP-155, signed transactions on each network would look the same, and could be replayed.