> For the complete documentation index, see [llms.txt](https://change-chain-1.gitbook.io/change-chain/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://change-chain-1.gitbook.io/change-chain/architecture/consensus.md).

# Consensus

## Consensus Mechanism

Change Chain employs a modified Proof-of-Work consensus algorithm optimized for high throughput and energy efficiency. This consensus mechanism ensures that all transactions are securely validated and recorded on the blockchain.

## Mining Algorithm

* **Memory-Hard Hashing Algorithm (Equihash-CX)**:
  * **Rationale**: To prevent ASIC domination and promote decentralization, Change Chain uses Equihash-CX, a memory-hard algorithm that requires significant RAM resources, making it more suitable for GPU mining.
  * **Parameters**:
    * **n**: 144 (memory parameter)
    * **k**: 5 (time parameter)
    * These parameters balance memory usage and computational effort, ensuring a fair mining environment.

## Block Structure

<figure><img src="https://2639828105-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDLeIVJqHiDrf1ktdSCyh%2Fuploads%2FsSEmObHuIUKgxezwG1NG%2Fimage.png?alt=media&amp;token=cc935462-269e-4711-929a-edd566b588ed" alt=""><figcaption></figcaption></figure>

* **Block Header**:
  * **Version**: Indicates the version of the block protocol.
  * **Previous Block Hash**: Links to the preceding block, ensuring chain integrity.
  * **Merkle Root**: Hash of all transactions in the block, enabling efficient verification.
  * **Timestamp**: Unix epoch time when the block was created.
  * **Difficulty Target**: Current network difficulty.
  * **Nonce**: Value adjusted by miners to find a valid hash.
* **Block Body**:
  * **Transactions**: List of all transactions included in the block.
  * **Miner's Reward Transaction (Coinbase)**: First transaction that awards the miner their block reward and fees.

**`Block Time`**`: Targets a sub 1-second block time`

## Difficulty Adjustment

**Dynamic Difficulty Adjustment Algorithm (DAA)**:

* Adjusts every block to maintain an average block time of less than 1 second.
* Uses a Weighted Harmonic Mean (WHM) of recent block times to smooth out fluctuations.
* Prevents sudden spikes or drops in difficulty, ensuring network stability.

&#x20;                                                                   $$\frac{n+1}{n}=\frac{D}{T\_{actual}}\times\frac{T\_{target}}{D}$$

**Where:**

* Dn+1D\_{n+1}Dn+1​ = Next difficulty
* DnD\_nDn​ = Current difficulty
* TtargetT\_{target}Ttarget​ = Target block time
* TactualT\_{actual}Tactual​ = Actual time taken to mine the last block

$$\frac{n+1}{n}=\frac{D}{T\_{actual}}\times\frac{T\_{target}}{D}$$
