Skip to main content

Solidity API

Factory

Provides functionality for creating and managing execution environments for DApps within the Atlas Protocol.

This contract uses deterministic deployment to generate and manage Execution Environment instances based on predefined templates.

EXECUTION_ENV_TEMPLATE

address EXECUTION_ENV_TEMPLATE

_FACTORY_BASE_SALT

bytes32 _FACTORY_BASE_SALT

constructor

constructor(address executionTemplate) internal

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.

createExecutionEnvironment

function createExecutionEnvironment(address control) external returns (address executionEnvironment)

Creates a new Execution Environment for the caller, given a DAppControl contract address.

Parameters

NameTypeDescription
controladdressThe address of the DAppControl contract for which the execution environment is being created.

Return Values

NameTypeDescription
executionEnvironmentaddressThe address of the newly created Execution Environment instance.

getExecutionEnvironment

function getExecutionEnvironment(address user, address control) external view returns (address executionEnvironment, uint32 callConfig, bool exists)

Retrieves the address and configuration of an existing execution environment for a given user and DApp control contract.

Parameters

NameTypeDescription
useraddressThe address of the user for whom the execution environment is being queried.
controladdressThe address of the DAppControl contract associated with the execution environment.

Return Values

NameTypeDescription
executionEnvironmentaddressThe address of the queried execution environment.
callConfiguint32The call configuration used by the execution environment, retrieved from the DAppControl contract.
existsboolA boolean indicating whether the execution environment already exists (true) or not (false).

_getOrCreateExecutionEnvironment

function _getOrCreateExecutionEnvironment(struct UserOperation userOp) internal returns (address executionEnvironment, struct DAppConfig dConfig)

Gets an existing execution environment or creates a new one if it does not exist for the specified user operation.

Parameters

NameTypeDescription
userOpstruct UserOperationThe user operation containing details about the user and the DAppControl contract.

Return Values

NameTypeDescription
executionEnvironmentaddressThe address of the execution environment that was found or created.
dConfigstruct DAppConfigThe DAppConfig for the execution environment, specifying how operations should be handled.

_getOrCreateExecutionEnvironment

function _getOrCreateExecutionEnvironment(address user, address control, uint32 callConfig) internal 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.

Return Values

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

_getExecutionEnvironmentCustom

function _getExecutionEnvironmentCustom(address user, address control, uint32 callConfig) internal 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.

Return Values

NameTypeDescription
executionEnvironmentaddressThe address of the user's execution environment.

_computeSalt

function _computeSalt(address user, address control, uint32 callConfig) internal view returns (bytes32)

_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.