Skip to main content

LSP23 Linked Contracts Factory

Introduction

Deploying smart contracts that are interdependent can be a complex process. Often, two or more contracts need each other's addresses at deployment, creating a circular dependency that can be challenging to resolve.

Circular Depedency

The LSP23 Linked Contracts Factory addresses this issue by providing a unified interface for deploying linked contracts with an optional post-deployment execution. This standard simplifies the deployment of complex contract systems, making it easier for developers to deploy interdependent contracts without the need for manual intervention.

What does this standard represent?

This standard represents a smart contract factory that allows users to deploy primary and secondary contracts that are linked together. It also supports deploying contracts as ERC1167 minimal proxies. The factory can execute post-deployment modules to perform additional logic after deploying the contracts (example: pass the address of the secondary contract to the primary contract's constructor / initializer function)

LSP23 Flow

Like LSP16, the LSP23 standard addresses the issue of deterministic address generation for contracts across different chains by generating the salt for contract deployment within the function, ensuring a fully decentralized deployment process. This approach guarantees consistent contract addresses across multiple chains and prevents "squatting addresses", enhancing the security and integrity of the deployment process.

Specification

tip

Check the LSP23 LinkedContractsFactory contract functions to know how to deploy contracts at the same address across different chains.

The LSP23LinkedContractsFactory contract provides two main functions for deploying linked contracts: deployContracts and deployERC1167Proxies. Both functions allow the deployment of primary and secondary contracts, with optional post-deployment modules. You can find the IPostDeploymentModule interface.

Example

The deployment process for a Universal Profile and its associated Key Manager involves a series of steps that ensure proper integration and ownership assignment between the two contracts. The Universal Profile serves as the primary contract, while the Key Manager functions as the secondary contract. Both contracts require each other's addresses during deployment.

Using, LSP23, the deployment flow is outlined as follows:

  • Deploy the Universal Profile, designating the post-deployment module as the initial owner of the Universal Profile.
  • Deploy the Key Manager, providing it with the address of the newly deployed Universal Profile.
  • Execute the post-deployment module to transfer ownership of the Universal Profile to the Key Manager. Additionally, carry out any other post-deployment logic as necessary.

Universal Profile Deployment