Skip to main content

Solidity API

FactoryLib

EXECUTION_ENV_TEMPLATE

address EXECUTION_ENV_TEMPLATE

constructor

constructor(address executionTemplate) public

Initializes a new Factory contract instance by setting the immutable salt for deterministic deployment of Execution Environments and storing the execution template address.

The Execution Environment Template must be separately deployed using the same calculated salt.

Parameters

NameTypeDescription
executionTemplateaddressAddress of the pre-deployed execution template contract for creating Execution Environment instances.

getOrCreateExecutionEnvironment

function getOrCreateExecutionEnvironment(address user, address control, uint32 callConfig, bytes32 salt) public payable returns (address executionEnvironment)

Deploys a new execution environment or retrieves the address of an existing one based on the DApp control, user, and configuration.

Uses the create2 opcode for deterministic deployment, allowing the calculation of the execution environment's address before deployment. The deployment uses a combination of the DAppControl address, user address, call configuration, and a unique salt to ensure the uniqueness and predictability of the environment's address.

Parameters

NameTypeDescription
useraddressThe address of the user for whom the execution environment is being set.
controladdressThe address of the DAppControl contract providing the operational context.
callConfiguint32CallConfig settings of the DAppControl contract.
saltbytes32

Return Values

NameTypeDescription
executionEnvironmentaddressThe address of the newly created or already existing execution environment.

getExecutionEnvironmentCustom

function getExecutionEnvironmentCustom(address user, address control, uint32 callConfig, bytes32 salt) public view returns (address executionEnvironment)

Generates the address of a user's execution environment affected by deprecated callConfig changes in the DAppControl.

Calculates the deterministic address of the execution environment based on the user, control, callConfig, and controlCodeHash, ensuring consistency across changes in callConfig.

Parameters

NameTypeDescription
useraddressThe address of the user for whom the execution environment's address is being generated.
controladdressThe address of the DAppControl contract associated with the execution environment.
callConfiguint32The configuration flags defining the behavior of the execution environment.
saltbytes32

Return Values

NameTypeDescription
executionEnvironmentaddressThe address of the user's execution environment.

_getMimicCreationCode

function _getMimicCreationCode(address user, address control, uint32 callConfig) internal view returns (bytes creationCode)

Generates the creation code for the execution environment contract.

Parameters

NameTypeDescription
useraddressThe address of the user for whom the execution environment is being created, contributing to the uniqueness of the creation code.
controladdressThe address of the DAppControl contract associated with the execution environment.
callConfiguint32The configuration flags defining the behavior of the execution environment.

Return Values

NameTypeDescription
creationCodebytesThe bytecode representing the creation code of the execution environment contract.