Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

IApplicationFactory

Git Source

Inherits: IVersionGetter, IApplicationFactoryErrors

Title: Application Factory interface

Functions

newApplication

Deploy a new application.

On success, MUST emit an ApplicationCreated event.

Reverts if the application owner address is zero.

function newApplication(
    IOutputsMerkleRootValidator outputsMerkleRootValidator,
    address appOwner,
    bytes32 templateHash,
    IInputBox inputBox,
    WithdrawalConfig calldata withdrawalConfig
) external returns (IApplication);

Parameters

NameTypeDescription
outputsMerkleRootValidatorIOutputsMerkleRootValidatorThe initial outputs Merkle root validator contract
appOwneraddressThe initial application owner
templateHashbytes32The initial machine state hash
inputBoxIInputBoxThe input box contract
withdrawalConfigWithdrawalConfigThe withdrawal configuration

Returns

NameTypeDescription
<none>IApplicationThe application

newApplication

Deploy a new application deterministically.

On success, MUST emit an ApplicationCreated event.

Reverts if the application owner address is zero.

function newApplication(
    IOutputsMerkleRootValidator outputsMerkleRootValidator,
    address appOwner,
    bytes32 templateHash,
    IInputBox inputBox,
    WithdrawalConfig calldata withdrawalConfig,
    bytes32 salt
) external returns (IApplication);

Parameters

NameTypeDescription
outputsMerkleRootValidatorIOutputsMerkleRootValidatorThe initial outputs Merkle root validator contract
appOwneraddressThe initial application owner
templateHashbytes32The initial machine state hash
inputBoxIInputBoxThe input box contract
withdrawalConfigWithdrawalConfigThe withdrawal configuration
saltbytes32The salt used to deterministically generate the application contract address

Returns

NameTypeDescription
<none>IApplicationThe application

calculateApplicationAddress

Calculate the address of an application contract to be deployed deterministically.

Beware that only the newApplication function with the salt parameter is able to deterministically deploy an application.

function calculateApplicationAddress(
    IOutputsMerkleRootValidator outputsMerkleRootValidator,
    address appOwner,
    bytes32 templateHash,
    IInputBox inputBox,
    WithdrawalConfig calldata withdrawalConfig,
    bytes32 salt
) external view returns (address);

Parameters

NameTypeDescription
outputsMerkleRootValidatorIOutputsMerkleRootValidatorThe initial outputs Merkle root validator contract
appOwneraddressThe initial application owner
templateHashbytes32The initial machine state hash
inputBoxIInputBoxThe input box contract
withdrawalConfigWithdrawalConfigThe withdrawal configuration
saltbytes32The salt used to deterministically generate the application contract address

Returns

NameTypeDescription
<none>addressThe deterministic application contract address

Events

ApplicationCreated

A new application was deployed.

MUST be triggered on a successful call to newApplication.

event ApplicationCreated(
    IOutputsMerkleRootValidator indexed outputsMerkleRootValidator,
    address appOwner,
    bytes32 templateHash,
    IInputBox inputBox,
    WithdrawalConfig withdrawalConfig,
    IApplication appContract
);

Parameters

NameTypeDescription
outputsMerkleRootValidatorIOutputsMerkleRootValidatorThe initial outputs Merkle root validator contract
appOwneraddressThe initial application owner
templateHashbytes32The initial machine state hash
inputBoxIInputBoxThe input box contract
withdrawalConfigWithdrawalConfig
appContractIApplicationThe application contract