Skip to main content
This resource is a collection of use cases and patterns for assertions. The goal is to show how assertions can be used to prevent hacks and vulnerabilities in smart contracts and protocols. The content of the book is a great source for inspiration for how to write assertions for your own use cases and protocols. The book consists of two main parts: assertions that demonstrate specific assertion patterns and examples, and previous hacks that show how assertions could have prevented real-world exploits. 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.

Getting Started

It’s a good idea to check out the two links below to get started with assertions, but it’s not required to understand the content of the book. 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: Real World Protocols

Complete assertion suites for production protocols. These examples show how to protect real-world systems with comprehensive assertion coverage. View real world protocol suites →

Part 2: Previous Hacks

Analysis of real-world DeFi hacks and how assertions could have prevented them. These case studies show how assertions catch vulnerabilities that slip through audits and testing. View the previous hacks analysis →

Part 3: General Use Cases

Curated assertion patterns organized by security category. These examples demonstrate proactive security measures you can implement to protect your protocols. 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.