Skip to main content

InputBox

The InputBox is a trustless and permissionless contract that receives arbitrary blobs (called "inputs") from anyone and adds a compound hash to an append-only list (called "input box"). Each dApp has its input box.

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

Data availability is guaranteed by 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 the perspective of this contract, inputs are encoding-agnostic byte arrays. It is up to the dApp to interpret, validate, and act upon inputs.

InputAdded()

event InputAdded(address dapp, uint256 inboxInputIndex, address sender, bytes input)

Emitted when an input is added to a dApp's input box.

Parameters

NameTypeDescription
dappaddressThe address of the dApp
inboxInputIndexuint256The index of the input in the input box
senderaddressThe address that sent the input
inputbytesThe contents of the input

addInput()

function addInput(address _dapp, bytes _input) external returns (bytes32)

Add an input to a dApp's input box.

MUST fire an InputAdded event accordingly.

Parameters

NameTypeDescription
_dappaddressThe address of the dApp
_inputbytesThe contents of the input

Return Values

NameTypeDescription
[0]bytes32The hash of the input plus some extra metadata

getNumberOfInputs()

function getNumberOfInputs(address _dapp) external view returns (uint256)

Get the number of inputs in a dApp's input box.

Parameters

NameTypeDescription
_dappaddressThe address of the dApp

Return Values

NameTypeDescription
[0]uint256Number of inputs in the dApp's input box

getInputHash()

function getInputHash(address _dapp, uint256 _index) external view returns (bytes32)

Get the hash of an input in a dApp's input box.

_index MUST be in the interval [0,n) where n is the number of inputs in the dApp's input box. See the getNumberOfInputs function.

Parameters

NameTypeDescription
_dappaddressThe address of the dApp
_indexuint256The index of the input in the dApp's input box

Return Values

NameTypeDescription
[0]bytes32The hash of the input at the provided index in the dApp's input box

© 2024 Cartesi Foundation Ltd. All rights reserved.

The Cartesi Project is commissioned by the Cartesi Foundation.

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.