Application
Inherits: IApplication, Ownable, ERC721Holder, ERC1155Holder, ReentrancyGuard
State Variables
DEPLOYMENT_BLOCK_NUMBER
Deployment block number
uint256 immutable DEPLOYMENT_BLOCK_NUMBER = block.number
TEMPLATE_HASH
The initial machine state hash.
See the getTemplateHash function.
bytes32 immutable TEMPLATE_HASH
_executed
Keeps track of which outputs have been executed.
See the wasOutputExecuted function.
BitMaps.BitMap internal _executed
_outputsMerkleRootValidator
The current outputs Merkle root validator contract.
See the getOutputsMerkleRootValidator and migrateToOutputsMerkleRootValidator functions.
IOutputsMerkleRootValidator internal _outputsMerkleRootValidator
_dataAvailability
The data availability solution.
See the getDataAvailability function.
bytes internal _dataAvailability
_numOfExecutedOutputs
The number of outputs executed by the application.
See the numberOfOutputsExecuted function.
uint256 _numOfExecutedOutputs
Functions
constructor
Creates an Application contract.
Reverts if the initial application owner address is zero.
constructor(
IOutputsMerkleRootValidator outputsMerkleRootValidator,
address initialOwner,
bytes32 templateHash,
bytes memory dataAvailability
) Ownable(initialOwner);
Parameters
| Name | Type | Description |
|---|---|---|
outputsMerkleRootValidator | IOutputsMerkleRootValidator | The initial outputs Merkle root validator contract |
initialOwner | address | The initial application owner |
templateHash | bytes32 | The initial machine state hash |
dataAvailability | bytes |
receive
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.
receive() external payable;
executeOutput
Execute an output.
On a successful execution, emits a OutputExecuted event.
function executeOutput(bytes calldata output, OutputValidityProof calldata proof)
external
override
nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
output | bytes | The output |
proof | OutputValidityProof | The proof used to validate the output against a claim accepted to the current outputs Merkle root validator contract |
migrateToOutputsMerkleRootValidator
Migrate the application to a new outputs Merkle root validator.
Can only be called by the application owner.
function migrateToOutputsMerkleRootValidator(IOutputsMerkleRootValidator newOutputsMerkleRootValidator)
external
override
onlyOwner;
Parameters
| Name | Type | Description |
|---|---|---|
newOutputsMerkleRootValidator | IOutputsMerkleRootValidator | The new outputs Merkle root validator |
wasOutputExecuted
Check whether an output has been executed.
function wasOutputExecuted(uint256 outputIndex)
external
view
override
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
outputIndex | uint256 | The index of output |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | Whether the output has been executed before |
validateOutput
Validate an output.
May raise any of the errors raised by validateOutputHash.
function validateOutput(bytes calldata output, OutputValidityProof calldata proof)
public
view
override;
Parameters
| Name | Type | Description |
|---|---|---|
output | bytes | The output |
proof | OutputValidityProof | The proof used to validate the output against a claim accepted to the current outputs Merkle root validator contract |
validateOutputHash
Validate an output hash.
May raise InvalidOutputHashesSiblingsArrayLength
or InvalidOutputsMerkleRoot.
function validateOutputHash(bytes32 outputHash, OutputValidityProof calldata proof)
public
view
override;
Parameters
| Name | Type | Description |
|---|---|---|
outputHash | bytes32 | The output hash |
proof | OutputValidityProof | The proof used to validate the output against a claim accepted to the current outputs Merkle root validator contract |
getTemplateHash
Get the application's template hash.
function getTemplateHash() external view override returns (bytes32);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes32 | The application's template hash |
getOutputsMerkleRootValidator
Get the current outputs Merkle root validator.
function getOutputsMerkleRootValidator()
external
view
override
returns (IOutputsMerkleRootValidator);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IOutputsMerkleRootValidator | The current outputs Merkle root validator |
getDataAvailability
Get the data availability solution used by application.
function getDataAvailability() external view override returns (bytes memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes | Solidity ABI-encoded function call that describes the source of inputs that should be fed to the application. |
getDeploymentBlockNumber
Get number of block in which contract was deployed
function getDeploymentBlockNumber() external view override returns (uint256);
getNumberOfExecutedOutputs
Get number of outputs executed by the application.
function getNumberOfExecutedOutputs() external view override returns (uint256);
owner
Returns the address of the current owner.
function owner() public view override(IOwnable, Ownable) returns (address);
renounceOwnership
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.
function renounceOwnership() public override(IOwnable, Ownable);
transferOwnership
Transfers ownership of the contract to a new account (newOwner).
Can only be called by the current owner.
function transferOwnership(address newOwner) public override(IOwnable, Ownable);
_isOutputsMerkleRootValid
Check if an outputs Merkle root is valid, according to the current outputs Merkle root validator.
function _isOutputsMerkleRootValid(bytes32 outputsMerkleRoot)
internal
view
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
outputsMerkleRoot | bytes32 | The output Merkle root |
_executeVoucher
Executes a voucher
function _executeVoucher(bytes calldata arguments) internal;
Parameters
| Name | Type | Description |
|---|---|---|
arguments | bytes | ABI-encoded arguments |
_executeDelegateCallVoucher
Executes a delegatecall voucher
function _executeDelegateCallVoucher(bytes calldata arguments) internal;
Parameters
| Name | Type | Description |
|---|---|---|
arguments | bytes | ABI-encoded arguments |