Skip to main content
The Assertions Book has two jobs:
  • Reference: a catalog of reusable assertion patterns you can adapt to your own protocol
  • Explanation: case studies that explain how real exploits worked and why specific assertions would have blocked them
Use this section when you want examples and inspiration. If you want a guided path for writing and deploying assertions, start in the Credible Layer docs. Each entry shows code snippets of assertions accompanied by minimal interfaces for the protocols they protect. Full examples that include mock protocol code and test cases are available in the Phylax Assertion Examples Repository.

How to Use This Book

Browse Assertion Patterns

Use the reference catalog when you already know the type of risk you want to cover.

Study Real Exploits

Use the case studies when you want to understand why an exploit worked and what assertion would have stopped it.

See Full Protocol Suites

Review deeper examples that show how assertion coverage can be shaped for a real protocol.

Start Building

Leave the book and follow a tutorial when you want to build your own assertion from scratch.
If you have questions or issues, please reach out on telegram @phylax_credible_layer. If you think an assertion is missing, please don’t hesitate to open a PR or reach out. We love digging into new hacks and use cases and writing assertions for them!

Book Structure

This book is organized into three sections:

Part 1: Protocol Case Studies

Explanation pages that show how comprehensive assertion coverage can be designed for real systems. View real world protocol suites →

Part 2: Previous Hacks

Explanation pages that analyze real-world DeFi hacks and show how assertions could have prevented them. View the previous hacks analysis →

Part 3: Assertion Patterns

Reference pages that catalog reusable assertion patterns by security category. View the complete use cases catalog → All sections include assertion code examples, explanations of the vulnerability or pattern being addressed, and minimal protocol interfaces for context.