Skip to main content

Application

The Application contract serves as the base layer representation of the application running on the execution layer. The application can interact with other smart contracts through the execution and validation of outputs. These outputs, generated by the application backend on the execution layer, can be proven in the base layer through claims submitted by a consensus contract.

Every Application is subscribed to a consensus contract and governed by a single address (owner). The consensus has the authority to submit claims, which are then used to validate outputs. The owner has complete control over the Application and can replace the consensus at any time. Consequently, users of an Application must trust both the consensus and the application owner. Depending on centralization or ownership concerns, the ownership model can be modified. This process is managed by the consensus contract. For more information about different ownership and consensus models, refer to the consensus contracts.

Functions

constructor()

constructor(
IOutputsMerkleRootValidator outputsMerkleRootValidator,
address initialOwner,
bytes32 templateHash,
bytes memory dataAvailability
) Ownable(initialOwner)

Creates an Application contract.

Parameters

NameTypeDescription
outputsMerkleRootValidatorIOutputsMerkleRootValidatorThe initial outputs Merkle root validator contract
initialOwneraddressThe initial application owner
templateHashbytes32The initial machine state hash
dataAvailabilitybytesThe data availability solution

receive()

receive() external payable

Accept Ether transfers.

If you wish to transfer Ether to an application while informing the backend of it, then please do so through the Ether portal contract.

executeOutput()

function executeOutput(bytes calldata output, OutputValidityProof calldata proof) external override nonReentrant

Execute an output.

On a successful execution, emits an OutputExecuted event.

Parameters

NameTypeDescription
outputbytesThe output
proofOutputValidityProofThe proof used to validate the output against a claim accepted to the current outputs Merkle root validator contract

migrateToOutputsMerkleRootValidator()

function migrateToOutputsMerkleRootValidator(IOutputsMerkleRootValidator newOutputsMerkleRootValidator) external override onlyOwner

Migrate the application to a new outputs Merkle root validator.

Can only be called by the application owner.

Parameters

NameTypeDescription
newOutputsMerkleRootValidatorIOutputsMerkleRootValidatorThe new outputs Merkle root validator

wasOutputExecuted()

function wasOutputExecuted(uint256 outputIndex) external view override returns (bool)

Check whether an output has been executed.

Parameters

NameTypeDescription
outputIndexuint256The index of output

Return Values

NameTypeDescription
[0]boolWhether the output has been executed before

validateOutput()

function validateOutput(bytes calldata output, OutputValidityProof calldata proof) public view override

Validate an output.

May raise any of the errors raised by validateOutputHash.

Parameters

NameTypeDescription
outputbytesThe output
proofOutputValidityProofThe proof used to validate the output against a claim accepted to the current outputs Merkle root validator contract

validateOutputHash()

function validateOutputHash(bytes32 outputHash, OutputValidityProof calldata proof) public view override

Validate an output hash.

May raise InvalidOutputHashesSiblingsArrayLength or InvalidOutputsMerkleRoot.

Parameters

NameTypeDescription
outputHashbytes32The output hash
proofOutputValidityProofThe proof used to validate the output against a claim accepted to the current outputs Merkle root validator contract

getTemplateHash()

function getTemplateHash() external view override returns (bytes32)

Get the application's template hash.

Return Values

NameTypeDescription
[0]bytes32The application's template hash

getOutputsMerkleRootValidator()

function getOutputsMerkleRootValidator() external view override returns (IOutputsMerkleRootValidator)

Get the current outputs Merkle root validator.

Return Values

NameTypeDescription
[0]IOutputsMerkleRootValidatorThe current outputs Merkle root validator

getDataAvailability()

function getDataAvailability() external view override returns (bytes memory)

Get the data availability solution used by application.

Return Values

NameTypeDescription
[0]bytesSolidity ABI-encoded function call that describes the source of inputs that should be fed to the application.

getDeploymentBlockNumber()

function getDeploymentBlockNumber() external view override returns (uint256)

Get number of block in which contract was deployed.

Return Values

NameTypeDescription
[0]uint256The deployment block number

owner()

function owner() public view override(IOwnable, Ownable) returns (address)

Returns the address of the current owner.

Return Values

NameTypeDescription
[0]addressThe address of the current owner

renounceOwnership()

function renounceOwnership() public override(IOwnable, Ownable)

Leaves the contract without owner. It will not be possible to call onlyOwner functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.

transferOwnership()

function transferOwnership(address newOwner) public override(IOwnable, Ownable)

Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.

Parameters

NameTypeDescription
newOwneraddressThe new owner address

Events

OutputExecuted()

event OutputExecuted(uint64 outputIndex, bytes output)

An output was executed from the Application.

Parameters

NameTypeDescription
outputIndexuint64The index of the output
outputbytesThe output

OutputsMerkleRootValidatorChanged()

event OutputsMerkleRootValidatorChanged(IOutputsMerkleRootValidator newOutputsMerkleRootValidator)

The outputs Merkle root validator was changed.

Parameters

NameTypeDescription
newOutputsMerkleRootValidatorIOutputsMerkleRootValidatorThe new outputs Merkle root validator

On this page

Useful resources to learn more

We use cookies to ensure that we give you the best experience on our website. By using the website, you agree to the use of cookies.