### Nodes Nodes are the peer-to-peer network participants which perform the following functions: 1. Maintaining correct, uncorrupted copies of the [[Bitcoin Anatomy#Blockchain|blockchain]] (e.g., running a full node). 2. Cryptographically verifying messages, signatures, and asset ownership 3. Validating, confirming, or "signing" transactions and [[Bitcoin Anatomy#Block|blocks]]. ### Block A block includes validated transactions and is added to the Bitcoin blockchain approximately every ten minutes. The block height of the Bitcoin blockchain is the number of blocks mined. Block sizes vary across blockchain implementations. *More is coming later on block weights, block heights, and block sizes*. ### Blockchain A chain of blocks of course gives us a blockchain, which is sometimes referred to as a public ledger. This chain is created and maintained by a network of [[Bitcoin Anatomy#Nodes|nodes]]. In public ledger blockchains, transactions are shown in a transparent online record. Once a block is added, all transactions in that block have been indelibly written for all to see. Importantly, core functions of blockchain - [[Consensus Mechanism|consensus]], [[Finality|finality]], and [[Immutability|immutability]] - rely upon statefulness. [[Bitcoin#Bitcoin the Monetary Network|Bitcoin as a monetary network]] is described as a state transition system. The state of the blockchain is a snapshot of all token ownership at block `x`. The transition occurs in between blocks with the new ownership state observed at block `xʹ`, so on and so forth. Each block is mined when a node (or mining pool) discovers a [[Bitcoin Anatomy#Nonce|nonce]] with a [[Bitcoin Anatomy#Hash|hash]] value below or equal to the target hash value determined by the [[Difficulty|difficulty]] algorithm. ### Block Header A block header includes the cryptographic messages which allow miners to validate all blocks and similarly all transactions in the blockchain. A header includes the following information: - [[Bitcoin Anatomy#Hash|Hash]] - [[Bitcoin Anatomy#Merkle Root|Merkle Root]] - [[Bitcoin Anatomy#Nonce|Nonce]] - [[Bitcoin Anatomy#Timestamp|Timestamp]] ### Hash A hash is a hexadecimal value generated by running a cryptographic algorithm on some electronic data (bits). Each block header contains a hash of previous block, which more precisely is a 256-bit hexadecimal value generated by the SHA-256 hashing algorithm. As Bitcoin [[Difficulty|difficulty]] increases, the maximum target for the hash value decreases, and miners or stakers must find a [[Bitcoin Anatomy#Nonce|nonce]] which generates a [[Bitcoin Anatomy#Hash|hash]] at or below that target value. ### Merkle Root A Merkle root is a hash of all the hashes of all the transactions in the block. It allows for a single hash to reference _all_ transaction hashes, which would change if even one transaction in a Merkle tree was altered/removed. Since blocks are tamper-proof, a Merkle root is a verification hash to check all transactions in a block. Similarly, a Merkle root can verify all transactions in the chain of blocks, as the block header includes a hash referencing the hash of prior transaction blocks. This allows nodes to confirm transactions and blocks without having to download the entire blockchain. ### Nonce A nonce is a 32-bit arbitrary number, and the term means "Number Used Only Once". It is used both for the purposes of validating blocks and for validating transaction signatures. When validating blocks, miners and stakers must test nonces until a discovering a [[Bitcoin Anatomy#Hash|hash]] at/below the target (a value set by the [[Difficulty|difficulty]] algorithm). When this occurs, other nodes in the network recheck the nonce's hash value before validating that [[Bitcoin Anatomy#Block|block]]. Now, a new block can be added to the chain, and new coins are awarded to the miner(s) who found the nonce. This arduous and time-sensitive process is what maintains the integrity/security of [[Proof of Work]] blockchains. >[!note] Nonces are also used in the [[Ethereum]] blockchain. The differences in Ethereum blocks, and the implementations, are quite robust and have been extensively documented [here](https://ethereum.org/en/developers/docs/blocks/). When creating a transaction, the sender needs to sign it with their private key to prove ownership and authorize its execution. The nonce ensures that each transaction from an account is unique and executed only once. In this context, the nonce acts as a unique identifier associated with the sender's account. this unique value prevents forgery of digital signatures and thwarts replay attacks. ### Timestamp An agreed-upon system clock is critical to the difficulty algorithm as well as the security of the blockchain.