> For the complete documentation index, see [llms.txt](https://docs.qms.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.qms.finance/overview/how-qms-works-at-a-glance.md).

# How QMS Works at a Glance

The QMS blockchain is organized into four layers, each handling a distinct responsibility.

<figure><img src="https://4237698239-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhlxcI4pd9LbQ4gbo3eSr%2Fuploads%2Fgit-blob-769e49ec6d467612f5399219cc77fef66861074b%2FArchitecture.svg?alt=media" alt="The four layers of the QMS protocol stack"><figcaption><p>The QMS protocol stack. The four QMS layers—network, consensus, finality, and execution—sit between the public internet below and the application layer above.</p></figcaption></figure>

1. **Network Layer**: peer-to-peer communication and catch-up.
2. **Consensus Layer**: block production via proof-of-useful-work and chain selection.
3. **Finality Layer**: explicit finality through a stake-based finalizer set.
4. **Execution Layer**: transaction processing and smart contract execution, compatible with the Ethereum Virtual Machine (EVM).

QMS takes the network layer and execution layer mostly untouched from Ethereum, inheriting a mature codebase and EVM compatibility. The consensus layer and finality layer are custom-made to support useful work, quantum miners, and post-quantum (PQ) security.

## Network Layer

The network layer handles peer discovery, peer-to-peer message propagation, block dissemination, and catch-up for nodes that join or have fallen behind.

## Consensus Layer

The consensus layer orders transactions into blocks and resolves which chain is canonical when miners produce competing ones. QMS's consensus client, Casimir, secures the chain with proof-of-useful-work (PoUW), a proof-of-work protocol in which miners run a solver on real-world optimization problems rather than computing hashes.

The initial problem class is quadratic unconstrained binary optimization (QUBO), which covers many practical applications in finance and data analysis. The modular PoUW implementation allows further problem classes to be added as the network matures.

Block production rights are awarded by a lottery over valid solver outputs, independently of solution quality, so pre-solving submitted problems gives an adversary no advantage. Above the last finalized block, the canonical chain is the heaviest chain, the one with the most cumulative work. Block production and chain selection both rely on computational work rather than signatures and staking, making the consensus layer quantum-resistant by design.

### The Useful-Work Marketplace

<figure><img src="https://4237698239-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhlxcI4pd9LbQ4gbo3eSr%2Fuploads%2Fgit-blob-a02d9028fc7e2f360f92aca1df17fb160b0d925c%2FMarketplace.svg?alt=media" alt="Clients, the marketplace, and miners in the proof-of-useful-work loop"><figcaption><p>The PoUW marketplace. Clients post problems to the marketplace and lock tokens to pay for good solutions. Miners take problems from the marketplace, run solvers against them, and submit good solutions, which the marketplace pays for in tokens and returns to the client. A solver run that wins the block-production lottery produces the next block in the chain.</p></figcaption></figure>

Clients post problems to an on-chain marketplace and lock funds into a smart contract to pay for good solutions. Miners choose problems from the marketplace and run a solver against them. Good solutions are submitted back on-chain, and the smart contract distributes the locked payments to the miners that produced them.

## Finality Layer

The finality layer uses a PQ signature algorithm to mark blocks as final, guaranteeing they will never be rolled back. Finalizers stake the native token and vote on which blocks to finalize. Once a block is finalized, all of its ancestors are finalized with it. The finality layer runs alongside the consensus protocol. Under ideal conditions, blocks are finalized shortly after they are produced.

The finality layer launches with a known, permissioned finalizer set, operated by entities accountable to QMS Network, who do not stake. While mining power is still modest and the token distribution centralized, the set guards against an opportunistic 51% attack and acts as a safety net as PoUW parameters are calibrated on a live network. As the network matures, the finalizer set opens to participants who stake the native token.

## Execution Layer

The execution layer processes transactions and runs smart contracts. QMS uses a standard Ethereum execution client, making the chain EVM-compatible. Existing wallets, block explorers, and developer tooling work without modification, and smart contracts deployed on Ethereum can be migrated with no code changes. Transactions are priced in the native token, but the EIP-1559 fee structure is inherited from Ethereum.

*Adapted from Sections 2.5, 3, 4.2, and 5.4 of the* [*white paper*](https://docs.qms.finance/whitepaper)*.*\
*Further reading: the white paper analyses the security of proof-of-useful-work in Section 4.4, specifies the finality layer in Section 5, and traces the token flows in Section 7.*
