# Smart Contracts

## CommitmentsInbox&#x20;

**What it does:** The CommitmentsInbox contract receives and processes block headers and other data sent from Layer 1 to Layer 2. It verifies the authenticity of the data using signatures and stores it for further processing. \
\
**Relevance:** This contract is crucial for ensuring secure and reliable data transfer from Layer 1 to Layer 2, maintaining data integrity in cross-chain operations.

## FactsRegistry&#x20;

**What it does:** The FactsRegistry contract stores and manages verified blockchain data, such as account balances, storage values, and block headers. It provides functions to prove and access this data on-chain.&#x20;

**Relevance:** This contract is the core of the Storage Proofs system, allowing smart contracts to access and verify data from other chains or historical states trustlessly.

## HeadersStore&#x20;

**What it does:** The HeadersStore contract manages a Merkle Mountain Range (MMR) of block headers. It allows for efficient storage and verification of a large number of block headers.&#x20;

**Relevance:** This contract enables efficient historical data access and verification, which is essential for cross-chain and historical data proofs.

## TimestampRemapper&#x20;

**What it does:** The TimestampRemapper contract maintains a mapping between timestamps and block numbers. It allows for efficient querying of block numbers by timestamp.&#x20;

**Relevance:** This contract is important for time-based queries and proofs, allowing users to reference data by time rather than block number.

## AggregatorsFactory&#x20;

**What it does:** The AggregatorsFactory contract creates and manages instances of SharpFactsAggregator contracts. These aggregators are responsible for accumulating and verifying proofs from the Starkware SHARP.&#x20;

**Relevance:** This contract is crucial for the scalability and efficiency of the Storage Proofs system, allowing for batched verification of multiple proofs.

## SharpFactsAggregator&#x20;

**What it does:** The SharpFactsAggregator contract receives and verifies batches of proofs from the SHARP system. It updates the state of the HeadersStore and FactsRegistry based on these verified proofs.&#x20;

**Relevance:** This contract is key to the efficient and secure updating of the Storage Proofs system state, bridging the off-chain proof generation with on-chain state updates.

## HeadersProcessor&#x20;

**What it does:** The HeadersProcessor contract verifies and processes block headers. It checks the validity of block headers and their relationship to previously processed headers.&#x20;

**Relevance:** This contract ensures the integrity and continuity of the block header chain, which is fundamental to the security of the Storage Proofs system.

## L1MessagesProxy&#x20;

**What it does:** The L1MessagesProxy contract acts as a proxy for sending messages from Layer 2 to Layer 1. It aggregates messages and handles the cross-chain communication protocol.&#x20;

**Relevance:** This contract is essential for enabling Layer 2 to Layer 1 communication, allowing for data and state updates to be propagated back to the main chain.

These contracts work together to create a secure, efficient, and flexible system for proving and accessing blockchain data across different chains and historical states. The system leverages zero-knowledge proofs and efficient data structures to minimize on-chain computation and storage while maintaining high security guarantees.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.storageproofs.com/architecture/smart-contracts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
