Skip to main content

InputBox

The InputBox is a trustless and permissionless contract that receives arbitrary data blobs (called "inputs") from any sender and adds a compound hash to an append-only list (the "input box").

The hash stored on-chain comprises the hash of the input blob, block number, timestamp, input sender address, and input index.

Data availability is guaranteed through the emission of InputAdded events on every successful call to addInput. This ensures that inputs can be retrieved by anyone at any time without relying on centralized data providers.

From this contract's perspective, inputs are encoding-agnostic byte arrays. It is the application's responsibility to interpret, validate, and act upon these inputs.

This contract inherits from IInputBox.

State Variables

_deploymentBlockNumber

Deployment block number

uint256 immutable _deploymentBlockNumber = block.number;

_inputBoxes

Mapping of application contract addresses to arrays of input hashes.

mapping(address => bytes32[]) private _inputBoxes;

Functions

addInput()

function addInput(address appContract, bytes calldata payload) external override returns (bytes32)

Send an input to an application.

Must fire an InputAdded event.

Parameters

NameTypeDescription
appContractaddressThe application contract address
payloadbytesThe input payload

Return Values

NameTypeDescription
[0]bytes32The hash of the input blob

getNumberOfInputs()

function getNumberOfInputs(address appContract) external view override returns (uint256)

Get the number of inputs sent to an application.

Parameters

NameTypeDescription
appContractaddressThe application contract address

Return Values

NameTypeDescription
[0]uint256Number of inputs in the application input box

getInputHash()

function getInputHash(address appContract, uint256 index) external view override returns (bytes32)

Get the hash of an input in an application's input box.

The provided index must be valid.

Parameters

NameTypeDescription
appContractaddressThe application contract address
indexuint256The input index

Return Values

NameTypeDescription
[0]bytes32The hash of the input at the provided index in the application input box

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

Events

InputAdded()

event InputAdded(address indexed appContract, uint256 indexed index, bytes input)

Emitted when an input is added to an application's input box.

Parameters

NameTypeDescription
appContractaddressThe application contract address
indexuint256The input index
inputbytesThe input blob

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.