> For the complete documentation index, see [llms.txt](https://docs.mezzanine.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mezzanine.xyz/smart-contracts/deployment-of-core-contracts.md).

# Deployment of Core Contracts

The Mezz Deployer is the smart contract responsible for deploying proxies of *core* contracts.  It is a *non-core* contract.  The Mezz Deployer specifically deploys new [minimal, non-upgradeable EIP-1167 proxies](https://eips.ethereum.org/EIPS/eip-1167) and [ERC1967 Proxies ](https://eips.ethereum.org/EIPS/eip-1967)that point to implementations of Mezzanine core contracts.  Proxies are used to reduce deployment costs since their runtime code is much smaller than that of implementations.  The cost of a contract's deployment is directly proportional to the size of its creation and runtime code.

Implementations are versioned and set in the *Mezz Migrator*.  Proxies deployed by the Mezz Deployer will always point to the latest implementations set in the Mezz Migrator.  Implementations are queried from the Mezz Migrator when provided *core identifiers*, which point to the latest version of an implementation.

Upon deployment, all proxies are initialized atomically.  Multiple major exploits have occurred from improper initialization.  Some core contracts deploy contracts from the Mezz Deployer and subsequently set state atomically.

<figure><img src="https://1470005141-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdHjZFJeNjVY4yO2OTNVA%2Fuploads%2FxSgIhyoPnBMFm2mFW3fC%2Fimage.png?alt=media&amp;token=9746ee2c-8fcd-41bf-8631-7f1af9b6f49b" alt=""><figcaption><p>Code Snippet from <em>TreasuryLogic.sol</em></p></figcaption></figure>

The initialization of deployments is *standardized* as a means to reduce the size of the Mezz Deployer.  Bespoke initialization arguments are passed via abi-encoded parameters.  For example, all assets in Mezzanine are deployed via the Mezzanine Deployer's *deployAsset* function.  Assets are all initialized in the same manner.  The validity of implementations is checked via ERC165.  In the below code, the function would revert if given a core identifier that does not correspond to an asset. &#x20;

<figure><img src="https://1470005141-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdHjZFJeNjVY4yO2OTNVA%2Fuploads%2F4sZwyeBc5BRd4wlDSEFS%2Fimage.png?alt=media&amp;token=8716bfd0-f8c9-4ac3-87a1-4ec38390c942" alt=""><figcaption><p>Mezz Deployer's <em>deployAsset</em> function</p></figcaption></figure>

*Learn more about Creation vs Runtime code* [*here*](https://blog.openzeppelin.com/deconstructing-a-solidity-contract-part-ii-creation-vs-runtime-6b9d60ecb44c)*.*

*Learn more about the gas cost for the CREATE opcode* [*here*](https://github.com/wolflo/evm-opcodes/blob/main/gas.md#a9-create-operations)*.*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mezzanine.xyz/smart-contracts/deployment-of-core-contracts.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
