App Address: {CARTESI_APP_ADDRESS}
+diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/delegate-call-vouchers.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/delegate-call-vouchers.md deleted file mode 100644 index 3edea9ce..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/delegate-call-vouchers.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -id: delegate-call-vouchers -title: DELEGATECALL Vouchers ---- - -:::danger Security Considerations -DELEGATECALL Vouchers are a powerful feature that should be used with extreme caution. Incorrect implementation can lead to serious security vulnerabilities as the target contract's code has full access to the Application contract's storage and funds. -::: - -DELEGATECALL Vouchers are an extension of vouchers that enables advanced smart contract interactions through the [`DELEGATECALL`](https://www.evm.codes/?fork=cancun#f4) opcode. - -Unlike regular vouchers, DELEGATECALL vouchers allow dApps to separate their execution logic from their storage context. When using DELEGATECALL voucher, the Application contract always maintains the storage, context, and funds (both ETH and tokens), while the target contract provides only the execution logic. This separation enables more flexible and reusable smart contract patterns while keeping all state changes and assets within the Application contract. - -When a DELEGATECALL voucher is executed through the Application contract, the code at the target address is executed with the following characteristics: - -- All storage operations occur in the Application contract's storage space -- All funds (ETH and tokens) remain in and are managed by the Application contract -- The msg.sender and msg.value from the original transaction are preserved -- The execution logic comes from the target contract, but operates on the Application contract's state and funds - -This mechanism, where the Application contract maintains the state and funds while borrowing logic from other contracts, enables powerful patterns such as: - -- **Paid Vouchers**: Vouchers that provide payment to the user who executes them. - -- **Future Vouchers**: Vouchers that are time-locked and can only be executed after a specific timestamp. - -- **Expirable Vouchers**: Vouchers that have an expiration timestamp, after which they can no longer be executed. - -- **Targeted Vouchers**: Vouchers that are restricted to execution by specific addresses or a list of authorized addresses. - -- **Atomic Vouchers**: A sequence of message calls that must be executed in order, ensuring atomicity of the operations. - -- **Re-executable Vouchers**: Vouchers that can be executed multiple times, unlike standard vouchers which can only be executed once. - -- **Ordered Vouchers**: Vouchers that must be executed in a specific sequence. For example, voucher A can only be executed after voucher B has been executed. - -The [`Application`](../contracts/application.md) contract handles the execution of DELEGATECALL vouchers through its [`executeOutput()`](../../contracts/application/#executeoutput) function, which validates and processes the DELEGATECALL operation on the blockchain. - -## Implementation Considerations - -When implementing DELEGATECALL vouchers, consider the following: - -1. **Storage Layout**: Since all storage operations happen in the Application contract, the storage layout of the target contract must be compatible with the Application contract's layout to prevent unintended storage collisions. - -2. **Security**: Since DELEGATECALL operations execute code in the context of the Application contract, careful validation of the target contract and its code is essential to prevent malicious modifications to the Application's state. - -3. **State Management**: All state changes occur in the Application contract's storage, making it the single source of truth for the application's state. - -:::note create a DELEGATECALL voucher -[Refer to the documentation here](../../development/asset-handling.md) for implementing DELEGATECALL vouchers in your dApp. -::: - -## Execution Context - -In a DELEGATECALL voucher execution: - -- The Application contract provides the execution context and storage -- The target contract provides only the logic to be executed -- All storage operations affect the Application contract's state -- msg.sender and msg.value from the original transaction are preserved - -This architecture, where the Application contract maintains all state while being able to execute logic from other contracts, makes DELEGATECALL vouchers particularly useful for customizable logics while keeping all application state centralized in the Application contract. - -## Epoch Configuration - -An epoch refers to a specific period during which a batch of updates is processed off-chain, and upon agreement by validators, the finalized state is recorded on-chain. - -Epoch Length is the number of blocks that make up an epoch. It determines how long each epoch lasts in terms of block counts. For instance, if an epoch length is set to 7200 blocks, the epoch will end once 7200 blocks have been processed. This length directly influences how frequently updates are finalized and recorded on the blockchain. - -Delegate call vouchers, like regular vouchers, are executed on the blockchain upon the closure of the corresponding epoch. This ensures that all state changes and logic executions are properly validated and recorded in the blockchain. - -You can manually set the epoch length to facilitate quicker execution of DELEGATECALL vouchers during development. - -:::note epoch duration -[Refer to the documentation here](../../development/cli-commands.md/#run) to manually configure epoch length during development. -::: \ No newline at end of file diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/exception.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/exception.md index 4b505136..90ec4ae1 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/exception.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/exception.md @@ -11,7 +11,7 @@ When an exception occurs during request processing, the dApp backend should: 3. Exit the processing loop The Rollup HTTP Server will: -- Skip the input with the reason [`EXCEPTION`](../graphql/enums/completion-status.md) +- Skip the input with the reason [`EXCEPTION`](../jsonrpc/types.md#inputcompletionstatus) - Forward the exception message - Return status code 200 diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/introduction.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/introduction.md index 223ab73e..ddb215a0 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/introduction.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/introduction.md @@ -3,16 +3,18 @@ id: introduction title: Introduction --- -The backend of a Cartesi dApp processes requests in the following manner: +The backend of a Cartesi dApp retrieves a new request as follows: - - **Finish** — Called via [`/finish`](./finish.md), indicates that any previous processing has been completed and the backend is ready to handle the next request. The subsequent request is returned as the call's response and can be of the following types: +- Finish — Communicates that any previous processing has been completed and that the backend is ready to handle the subsequent request. This following request is returned as the call's response and can be of the following types: - - **Advance** — Provides input to be processed by the backend to advance the Cartesi Machine state. When processing an Advance request, the backend can call the [`/voucher`](./vouchers.md), [`/delegate-call-voucher`](./delegate-call-vouchers.md), [`/notice`](./notices.md), and [`/report`](./reports.md) endpoints. For such requests, the input data contains both the payload and metadata, including the account address that submitted the input. + - **Advance** — Provides input to be processed by the backend to advance the Cartesi Machine state. When processing an `Advance` request, the backend can call the methods `/voucher`, `/notice`, and `/report`. For such requests, the input data contains the payload and metadata, such as the account address that submitted the input. - - **Inspect** — Submits a query about the application's current state. When running inside a Cartesi Machine, this operation is guaranteed to leave the state unchanged, as the machine reverts to its exact previous condition after processing. For Inspect requests, the input data contains only a payload, and the backend can only call the [`/report`](./reports.md) endpoint. + - **Inspect** — This function submits a query about the application's current state. When running inside a Cartesi Machine, this operation is guaranteed to leave the state unchanged since the machine is reverted to its exact previous condition after processing. For Inspect requests, the input data has only a payload. + + :::caution Inspect requests + Inspect requests are best suited for non-production use, such as debugging and testing. They may not function reliably in production environments, potentially leading to errors or disruptions. + ::: - - **Exception** — Called by the backend when it encounters an unrecoverable error during request processing. This signals to the Rollup HTTP Server that the current request processing failed and should be terminated. See [`/exception`](./exception.md) for more details. - ## Advance and Inspect Here is a simple boilerplate application that handles Advance and Inspect requests: @@ -120,34 +122,31 @@ while True: -An **Advance** request involves sending input data to the base layer via JSON-RPC, allowing it to reach the dApp backend to change the application's state. +An **Advance** request involves sending input data to the base layer via JSON-RPC so they can reach the dApp backend to change the application's state.  -Here is how an advance request works in the dApp architecture: +In the dApp architecture, here is how an advance request plays out. - Step 1: Send an input to the [`addInput(address, bytes)`](../contracts/input-box.md#addinput) function of the InputBox smart contract. -- Step 2: The HTTP Rollups Server reads the data and sends it to the Cartesi Machine for processing. +- Step 2: The HTTP Rollups Server reads the data and gives it to the Cartesi machine for processing. -- Step 3: After computation, the machine state is updated, and the results are returned to the rollup server. +- Step 3: After the computation, the machine state is updated, and the results are returned to the rollup server. -An **Inspect** request involves making an external HTTP API call to the rollups server to read the dApp state without modifying it. +An **Inspect** request involves making an external HTTP API call to the rollups server to read the dApp state without changing it.  You can make a simple inspect call from your frontend client to retrieve reports. -To perform an Inspect call, send an HTTP POST request to `
/inspect/
```javascript
-async function handle_advance(data) {
- console.log("Received advance request data " + JSON.stringify(data));
-
- const inputPayload = data["payload"];
+import { stringToHex, hexToString } from "viem";
+const emitNotice = async (inputPayload) => {
+ let hexPayload = stringToHex(inputPayload); // convert payload from string to hex
try {
await fetch(rollup_server + "/notice", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
- body: JSON.stringify({ payload: inputPayload }),
+ body: JSON.stringify({ payload: hexPayload }),
});
} catch (error) {
// Handle error here
}
+}
+async function handle_advance(data) {
+ console.log("Received advance request data " + JSON.stringify(data));
+ const payload = hexToString(data.payload); // convert input from hex to string for processing
+ await emitNotice(payload);
return "accept";
}
+
```
@@ -51,22 +56,16 @@ async function handle_advance(data) {
```python
-def handle_advance(data):
- logger.info(f"Received advance request data {data}")
-
- status = "accept"
- try:
- inputPayload = data["payload"]
- # Send the input payload as a notice
- response = requests.post(
- rollup_server + "/notice", json={"payload": inputPayload}
- )
- logger.info(
- f"Received notice status {response.status_code} body {response.content}"
- )
- except Exception as e:
- # Emit report with error message here
- return status
+# Notice creation Process from a message string
+def emit_notice(message):
+ notice_payload = {"payload": "0x" + message.encode("utf-8").hex()}
+ response = requests.post(rollup_server + "/notice", json=notice_payload)
+ if response.status_code == 200 or response.status_code == 201:
+ logger.info(f"Notice emitted successfully with data: {notice_payload}")
+ else:
+ logger.error(f"Failed to emit Notice with data: {notice_payload}. Status code: {response.status_code}")
+
+emit_notice("hello world")
```
@@ -75,5 +74,5 @@ def handle_advance(data):
:::note querying notices
-Frontend clients can query notices using a GraphQL API exposed by Cartesi Nodes. [Refer to the documentation here](../../development/query-outputs.md/#query-all-reports) to query notices from the rollup server.
+Frontend clients can query notices using a GraphQL API exposed by the Cartesi Nodes. [Refer to the documentation here](../../development/query-outputs.md/#query-all-reports) to query notices from the rollup server.
:::
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/vouchers.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/vouchers.md
index 1c0e9938..43b72538 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/vouchers.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/vouchers.md
@@ -6,13 +6,13 @@ title: Vouchers
Vouchers serve as a mechanism for facilitating on-chain actions initiated in the execution layer.
-Imagine vouchers as digital authorization tickets that grant dApps the authority to execute specific actions directly on the base layer. These vouchers encapsulate the details of the desired on-chain action, such as a token swap request or asset transfer.
+Imagine vouchers as digital authorization tickets, granting dApps the authority to execute specific actions directly on the base layer. This voucher encapsulates the details of the desired on-chain action, such as a token swap request or asset transfer.
-A voucher explicitly specifies the action that the dApp intends to execute on the base layer.
+The voucher explicitly specifies the action that the dApp intends to execute on the base layer.
For instance, in a DeFi application built on Cartesi, users may want to swap one token for another. The dApp generates a voucher that authorizes the on-chain smart contract to execute the swap on the user's behalf.
-The [`Application`](../contracts/application.md) contract is crucial in validating and executing the received voucher on the blockchain. This execution process occurs through the [`executeOutput()`](../../contracts/application/#executeoutput) function, which handles different types of outputs including vouchers and DELEGATECALL vouchers.
+The [`CartesiDApp`](../contracts/application.md) contract is crucial in validating and executing the received voucher on the blockchain. This execution process occurs through the [`executeVoucher()`](../contracts/application.md/#executevoucher) function, ensuring that the action specified in the voucher is legitimate and authorized.
The result of the voucher execution is recorded on the base layer. This recording typically involves submitting claims by a consensus contract, ensuring the integrity and transparency of the executed on-chain action.
@@ -20,17 +20,13 @@ The result of the voucher execution is recorded on the base layer. This recordin
[Refer to the documentation here](../../development/asset-handling.md) for asset handling and creating vouchers in your dApp.
:::
-## DELEGATECALL Vouchers
-
-Delegate call vouchers enable advanced smart contract interactions through the [DELEGATECALL](https://www.evm.codes/?fork=cancun#f4) opcode, allowing dApps to separate their execution logic from their storage context. For more details, see [DELEGATECALL Vouchers](./delegate-call-vouchers.md).
-
-## Epoch Configuration
+## Epoch configuration
An epoch refers to a specific period during which a batch of updates is processed off-chain, and upon agreement by validators, the finalized state is recorded on-chain.
Epoch Length is the number of blocks that make up an epoch. It determines how long each epoch lasts in terms of block counts. For instance, if an epoch length is set to 7200 blocks, the epoch will end once 7200 blocks have been processed. This length directly influences how frequently updates are finalized and recorded on the blockchain.
-One common use of vouchers in Cartesi dApps is to withdraw assets. Users initiate asset withdrawals by generating vouchers, which are then executed on the blockchain upon the closure of the corresponding epoch.
+One everyday use of vouchers in Cartesi dApps is to withdraw assets. Users initiate asset withdrawals by generating vouchers, which are then executed on the blockchain upon the closure of the corresponding epoch.
You can manually set the epoch length to facilitate quicker asset deposits and withdrawals.
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/application-factory.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/application-factory.md
index a1456c36..0818208c 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/application-factory.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/application-factory.md
@@ -2,104 +2,72 @@
id: application-factory
title: ApplicationFactory
resources:
- - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/dapp/ApplicationFactory.sol
+ - url: https://github.com/cartesi/rollups-contracts/blob/prerelease/2.0.0/contracts/dapp/ApplicationFactory.sol
title: Application Factory contract
---
-The **ApplicationFactory** contract allows anyone to reliably deploy a new `IApplication` contract.
+The **ApplicationFactory** contract is a tool for reliably deploying new instances of the [`Application`](../contracts/application.md) contract with or without a specified salt value for address derivation.
-This contract inherits from `IApplicationFactory`.
+Additionally, it provides a function to calculate the address of a potential new `CartesiDApp` contract based on input parameters.
-## Functions
+This contract ensures efficient and secure deployment of `Application` contracts within the Cartesi Rollups framework.
-### `newApplication()`
+## `newApplication()`
```solidity
-function newApplication(
- IOutputsMerkleRootValidator outputsMerkleRootValidator,
- address appOwner,
- bytes32 templateHash,
- bytes calldata dataAvailability
-) external override returns (IApplication)
+function newApplication( IConsensus consensus, address appOwner, bytes32 templateHash) external override returns (IApplication)
```
-Deploys a new Application contract without a salt value for address derivation.
+Deploys a new Application contract without specifying a salt value for address derivation.
Emits an `ApplicationCreated` event upon successful deployment.
-**Parameters**
+#### Parameters
-| Name | Type | Description |
-|------|------|-------------|
-| `outputsMerkleRootValidator` | `IOutputsMerkleRootValidator` | The initial outputs Merkle root validator contract |
-| `appOwner` | `address` | Address of the owner of the application |
-| `templateHash` | `bytes32` | Hash of the template for the application |
-| `dataAvailability` | `bytes` | The data availability solution |
+| Name | Type | Description |
+| ------------ | ---------- | ---------------------------------------- |
+| consensus | IConsensus | Instance of the consensus interface |
+| appOwner | address | Address of the owner of the application |
+| templateHash | bytes32 | Hash of the template for the application |
-**Return Values**
-
-| Name | Type | Description |
-|------|------|-------------|
-| `[0]` | `IApplication` | The deployed Application contract |
-
-### `newApplication()` (with salt)
+## `newApplication()`(with salt)
```solidity
-function newApplication(
- IOutputsMerkleRootValidator outputsMerkleRootValidator,
- address appOwner,
- bytes32 templateHash,
- bytes calldata dataAvailability,
- bytes32 salt
-) external override returns (IApplication)
+function newApplication( IConsensus consensus, address appOwner, bytes32 templateHash, bytes32 salt ) external override returns (IApplication)
```
Deploys a new `Application` contract with a specified salt value for address derivation.
Emits an `ApplicationCreated` event upon successful deployment.
-**Parameters**
-
-| Name | Type | Description |
-|------|------|-------------|
-| `outputsMerkleRootValidator` | `IOutputsMerkleRootValidator` | The initial outputs Merkle root validator contract |
-| `appOwner` | `address` | Address of the owner of the application |
-| `templateHash` | `bytes32` | Hash of the template for the application |
-| `dataAvailability` | `bytes` | The data availability solution |
-| `salt` | `bytes32` | Salt value for address derivation |
-
-**Return Values**
+#### Parameters
-| Name | Type | Description |
-|------|------|-------------|
-| `[0]` | `IApplication` | The deployed Application contract |
+| Name | Type | Description |
+| ------------ | ---------- | ---------------------------------------- |
+| consensus | IConsensus | Instance of the consensus interface |
+| appOwner | address | Address of the owner of the application |
+| templateHash | bytes32 | Hash of the template for the application |
+| salt | bytes32 | Salt value for address derivation |
### `calculateApplicationAddress()`
```solidity
-function calculateApplicationAddress(
- IOutputsMerkleRootValidator outputsMerkleRootValidator,
- address appOwner,
- bytes32 templateHash,
- bytes calldata dataAvailability,
- bytes32 salt
-) external view override returns (address)
+function calculateApplicationAddress( IConsensus consensus, address appOwner, bytes32 templateHash, bytes32 salt ) external view override returns (address)
```
Calculates the address of a potential new Application contract based on input parameters.
-**Parameters**
+#### Parameters
-| Name | Type | Description |
-|------|------|-------------|
-| `outputsMerkleRootValidator` | `IOutputsMerkleRootValidator` | The initial outputs Merkle root validator contract |
-| `appOwner` | `address` | Address of the owner of the application |
-| `templateHash` | `bytes32` | Hash of the template for the application |
-| `dataAvailability` | `bytes` | The data availability solution |
-| `salt` | `bytes32` | Salt value for address derivation |
+| Name | Type | Description |
+| ------------ | ---------- | ---------------------------------------- |
+| consensus | IConsensus | Instance of the consensus interface |
+| appOwner | address | Address of the owner of the application |
+| templateHash | bytes32 | Hash of the template for the application |
+| salt | bytes32 | Salt value for address derivation |
-**Return Values**
+#### Returns
-| Name | Type | Description |
-|------|------|-------------|
-| `[0]` | `address` | Address of the potential new Application contract |
+| Type | Description |
+| ------- | ------------------------------------------------- |
+| address | Address of the potential new Application contract |
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/application.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/application.md
index 50ead232..a8af6c7b 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/application.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/application.md
@@ -2,337 +2,167 @@
id: application
title: Application
resources:
- - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/dapp/Application.sol
+ - url: https://github.com/cartesi/rollups-contracts/tree/prerelease/2.0.0/contracts/dapp/Application.sol
title: Application contract
- url: https://docs.openzeppelin.com/contracts/5.x/
title: OpenZeppelin Contracts
---
-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.
+The **Application** contract acts as the base layer incarnation of the application running on the execution layer. The application can interact with other smart contracts through the execution and validation of outputs. The application backend on the execution layer generates these outputs, which can be proven in the base layer thanks to claims submitted by a consensus contract.
-Every Application is subscribed to a consensus contract and governed by a single address—the 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 [IConsensus](https://github.com/cartesi/rollups-contracts/blob/prerelease/2.0.0/contracts/consensus/IConsensus.sol).
+Every Application is subscribed to a consensus contract and governed by a single address, the owner. The consensus has the power to submit claims, which, in turn, are used to validate outputs. The owner has complete power over the Application, as it can replace the consensus at any time. Therefore, the users of an Application must trust both the consensus and the application owner. It is important to note that, depending on centralization or ownership concerns, it is possible to change the ownership model. This process is managed under the consensus contract. For more information about different ownership and consensus models, refer to the [IConsensus](https://github.com/cartesi/rollups-contracts/blob/prerelease/2.0.0/contracts/consensus/IConsensus.sol).
-This contract inherits from the following contracts:
+This contract inherits the following OpenZeppelin contracts.
-- `IApplication`
- `Ownable`
- `ERC721Holder`
- `ERC1155Holder`
- `ReentrancyGuard`
+- `IERC721Receiver`
+- `BitMaps`
For more information, please consult [OpenZeppelin's official documentation](https://docs.openzeppelin.com/contracts/5.x/).
-## State Variables
-
-### `_deploymentBlockNumber`
-Deployment block number
-
-```solidity
-uint256 immutable _deploymentBlockNumber = block.number;
-```
-
-### `_templateHash`
-The initial machine state hash.
-
-*See the `getTemplateHash` function.*
-
-```solidity
-bytes32 internal immutable _templateHash;
-```
-
-### `_executed`
-Keeps track of which outputs have been executed.
-
-*See the `wasOutputExecuted` function.*
-
-```solidity
-BitMaps.BitMap internal _executed;
-```
-
-### `_outputsMerkleRootValidator`
-The current outputs Merkle root validator contract.
-
-*See the `getOutputsMerkleRootValidator` and `migrateToOutputsMerkleRootValidator` functions.*
-
-```solidity
-IOutputsMerkleRootValidator internal _outputsMerkleRootValidator;
-```
-
-### `_dataAvailability`
-The data availability solution.
-
-*See the `getDataAvailability` function.*
-
-```solidity
-bytes internal _dataAvailability;
-```
-
-## Functions
-
-### `constructor`
-
-Creates an `Application` contract.
-
-*Reverts if the initial application owner address is zero.*
+## `executeOutput()`
```solidity
-constructor(
- IOutputsMerkleRootValidator outputsMerkleRootValidator,
- address initialOwner,
- bytes32 templateHash,
- bytes memory dataAvailability
-) Ownable(initialOwner);
+function executeOutput(bytes calldata output, OutputValidityProof calldata proof) external override nonReentrant (bool)
```
-**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` | The data availability solution |
-
-### `receive()`
-
-```solidity
-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()`
-
-```solidity
-function executeOutput(bytes calldata output, OutputValidityProof calldata proof) external override nonReentrant
-```
-
-Execute an output.
-
-*On a successful execution, emits a OutputExecuted event.*
-
-**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 |
+Try to execute an output.
-### `migrateToOutputsMerkleRootValidator()`
+Reverts if output was already successfully executed or if the caller is attempting to execute a non-executable output.
-```solidity
-function migrateToOutputsMerkleRootValidator(IOutputsMerkleRootValidator newOutputsMerkleRootValidator) external override onlyOwner
-```
-
-Migrate the application to a new outputs Merkle root validator.
+_On a successful execution, emits an `OutputExecuted` event._
-*Can only be called by the application owner.*
+### Parameters
-**Parameters**
+| Name | Type | Description |
+| ------------- | ------------ | -------------------------------------------------------------------------------------------------- |
+| output | bytes | The output contains, encapsulated in the form of bytes to be decoded within the function logic, the destination contract (address), the output value (uint256), and the payload (bytes) which encodes a function call. |
+| proof | struct OutputValidityProof | The proof used to validate the output against a claim submitted by the current consensus contract |
-| Name | Type | Description |
-|------|------|-------------|
-| `newOutputsMerkleRootValidator` | `IOutputsMerkleRootValidator` | The new outputs Merkle root validator |
-
-### `wasOutputExecuted()`
+## `wasOutputExecuted()`
```solidity
function wasOutputExecuted(uint256 outputIndex) external view override returns (bool)
```
-Check whether an output has been executed.
+Check whether a voucher has been executed.
-**Parameters**
+### Parameters
-| Name | Type | Description |
-|------|------|-------------|
-| `outputIndex` | `uint256` | The index of output |
+| Name | Type | Description |
+| ----------------- | ------- | ---------------------------------------- |
+| outputIndex | uint256 | The index of output emitted by the input |
-**Return Values**
+### Return Values
-| Name | Type | Description |
-|------|------|-------------|
-| `[0]` | `bool` | Whether the output has been executed before |
+| Name | Type | Description |
+| ---- | ---- | -------------------------------------------- |
+| [0] | bool | Whether the output has been executed before |
-### `validateOutput()`
+## `migrateToConsensus()`
```solidity
-function validateOutput(bytes calldata output, OutputValidityProof calldata proof) public view override
+function migrateToConsensus(IConsensus newConsensus) external override onlyOwner;
```
-Validate an output.
-
-*May raise any of the errors raised by validateOutputHash.*
-
-**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()`
-
-```solidity
-function validateOutputHash(bytes32 outputHash, OutputValidityProof calldata proof) public view override
-```
-
-Validate an output hash.
-
-*May raise InvalidOutputHashesSiblingsArrayLength or InvalidOutputsMerkleRoot.*
-
-**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()`
-
-```solidity
-function getTemplateHash() external view override returns (bytes32)
-```
-
-Get the application's template hash.
-
-**Return Values**
-
-| Name | Type | Description |
-|------|------|-------------|
-| `[0]` | `bytes32` | The application's template hash |
+Migrate the Application to a new consensus.
-### `getOutputsMerkleRootValidator()`
+_Can only be called by the Application owner._
-```solidity
-function getOutputsMerkleRootValidator() external view override returns (IOutputsMerkleRootValidator)
-```
-
-Get the current outputs Merkle root validator.
+### Parameters
-**Return Values**
+| Name | Type | Description |
+| -------------- | ------------------- | ----------------- |
+| \_newConsensus | contract IConsensus | The new consensus address |
-| Name | Type | Description |
-|------|------|-------------|
-| `[0]` | `IOutputsMerkleRootValidator` | The current outputs Merkle root validator |
-
-### `getDataAvailability()`
+## `validateOutput()`
```solidity
-function getDataAvailability() external view override returns (bytes memory)
+function validateOutput(bytes calldata output, OutputValidityProof calldata proof) public view override;
```
-Get the data availability solution used by application.
-
-**Return Values**
-
-| Name | Type | Description |
-|------|------|-------------|
-| `[0]` | `bytes` | Solidity ABI-encoded function call that describes the source of inputs that should be fed to the application. |
-
-### `getDeploymentBlockNumber()`
-
-```solidity
-function getDeploymentBlockNumber() external view override returns (uint256)
-```
+Validate an output.
-Get number of block in which contract was deployed.
+### Parameters
-**Return Values**
+| Name | Type | Description |
+| -------- | ---------------------- | --------------------------- |
+| output | bytes | The output |
+| proof | struct OutputValidityProof | Data for validating outputs |
-| Name | Type | Description |
-|------|------|-------------|
-| `[0]` | `uint256` | The deployment block number |
+Reverts if the output or its corresponding proof is invalid.
-### `owner()`
+## `validateOutputHash()`
```solidity
-function owner() public view override(IOwnable, Ownable) returns (address)
+function validateOutputHash(bytes32 outputHash, OutputValidityProof calldata proof) public view override;
```
-Returns the address of the current owner.
+Verifies the hash of an output against its proof.
-**Return Values**
+| Name | Type | Description |
+|--------------|-------------------------------|-----------------------------------|
+| outputHash | bytes32 | The hash of the output |
+| proof | struct OutputValidityProof | The proof used to validate the output against a claim submitted by the current consensus contract |
-| Name | Type | Description |
-|------|------|-------------|
-| `[0]` | `address` | The address of the current owner |
+Reverts if the proof's integrity check fails or if the output Merkle root hash was ever accepted by the consensus for a particular application.
-### `renounceOwnership()`
+## `getTemplateHash()`
```solidity
-function renounceOwnership() public override(IOwnable, Ownable)
+function getTemplateHash() external view returns (bytes32)
```
-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.
+Get the application template hash.
-### `transferOwnership()`
+### Return Values
-```solidity
-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**
+| Name | Type | Description |
+| ---- | ------- | ------------------------ |
+| [0] | bytes32 | The application template hash |
-| Name | Type | Description |
-|------|------|-------------|
-| `newOwner` | `address` | The new owner address |
-
-### `_isOutputsMerkleRootValid()`
+## `getConsensus()`
```solidity
-function _isOutputsMerkleRootValid(bytes32 outputsMerkleRoot) internal view returns (bool)
+function getConsensus() external view override returns (IConsensus);
```
-Check if an outputs Merkle root is valid, according to the current outputs Merkle root validator.
-
-**Parameters**
-
-| Name | Type | Description |
-|------|------|-------------|
-| `outputsMerkleRoot` | `bytes32` | The output Merkle root |
+Get the current consensus.
-**Return Values**
+### Return Values
-| Name | Type | Description |
-|------|------|-------------|
-| `[0]` | `bool` | Whether the outputs Merkle root is valid |
+| Name | Type | Description |
+| ---- | ------------------- | --------------------- |
+| [0] | contract IConsensus | The current consensus |
-### `_executeVoucher()`
+### `receive()`
```solidity
-function _executeVoucher(bytes calldata arguments) internal
+receive() external payable
```
-Executes a voucher.
-
-**Parameters**
+Accept Ether transfers.
-| Name | Type | Description |
-|------|------|-------------|
-| `arguments` | `bytes` | ABI-encoded arguments |
+_If the caller wants to transfer Ether to an application while informing the backend of it, then please do so through the Ether portal contract._
-### `_executeDelegateCallVoucher()`
+### `NewConsensus()`
```solidity
-function _executeDelegateCallVoucher(bytes calldata arguments) internal
+event NewConsensus(IConsensus newConsensus);
```
-Executes a delegatecall voucher.
-
-**Parameters**
+A new consensus is used, this event is emitted when a new consensus is set. This event must be triggered on a successful call to [migrateToConsensus](#migratetoconsensus).
-| Name | Type | Description |
-|------|------|-------------|
-| `arguments` | `bytes` | ABI-encoded arguments |
+### Parameters
-## Events
+| Name | Type | Description |
+| ------------ | ---------- | -------------------------- |
+| newConsensus | IConsensus | The new consensus contract |
-### `OutputExecuted()`
+## `OutputExecuted()`
```solidity
event OutputExecuted(uint64 outputIndex, bytes output);
@@ -340,9 +170,9 @@ event OutputExecuted(uint64 outputIndex, bytes output);
An output was executed from the Application, this event is emitted when a output is executed so it must be triggered on a successful call to [executeOutput](#executeOutput).
-**Parameters**
+### Parameters
-| Name | Type | Description |
-|------|------|-------------|
-| `outputIndex` | `uint64` | The index of the output |
-| `output` | `bytes` | The output |
+| Name | Type | Description |
+|--------------|---------|-----------------------|
+| outputIndex | uint64 | The index of the output |
+| output | bytes | The output |
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/abstract-consensus.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/abstract-consensus.md
new file mode 100644
index 00000000..89a4624f
--- /dev/null
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/abstract-consensus.md
@@ -0,0 +1,66 @@
+---
+id: abstract-consensus
+title: AbstractConsensus
+resources:
+ - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/consensus/AbstractConsensus.sol
+ title: AbstractConsensus Contract
+---
+
+The **AbstractConsensus** contract provides an abstract implementation of `IConsensus` with common consensus functionality.
+
+## Functions
+
+### `isOutputsMerkleRootValid()`
+
+```solidity
+function isOutputsMerkleRootValid(address appContract, bytes32 outputsMerkleRoot) public view override returns (bool)
+```
+
+Check whether an outputs Merkle root is valid.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `appContract` | `address` | The application contract address |
+| `outputsMerkleRoot` | `bytes32` | The outputs Merkle root |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `bool` | True if the outputs Merkle root is valid |
+
+### `getEpochLength()`
+
+```solidity
+function getEpochLength() public view override returns (uint256)
+```
+
+Get the epoch length.
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `uint256` | The epoch length |
+
+### `supportsInterface()`
+
+```solidity
+function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool)
+```
+
+Check if the contract supports a specific interface.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `interfaceId` | `bytes4` | The interface identifier |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `bool` | True if the interface is supported |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/authority/authority-factory.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/authority/authority-factory.md
new file mode 100644
index 00000000..d09cfece
--- /dev/null
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/authority/authority-factory.md
@@ -0,0 +1,80 @@
+---
+id: authority-factory
+title: AuthorityFactory
+resources:
+ - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/consensus/authority/AuthorityFactory.sol
+ title: AuthorityFactory Contract
+---
+
+The **AuthorityFactory** contract allows anyone to reliably deploy new `IAuthority` contracts.
+
+## Functions
+
+### `newAuthority()`
+
+```solidity
+function newAuthority(address authorityOwner, uint256 epochLength) external override returns (IAuthority)
+```
+
+Deploy a new authority contract.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `authorityOwner` | `address` | The initial authority owner |
+| `epochLength` | `uint256` | The epoch length |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `IAuthority` | The deployed authority contract |
+
+### `newAuthority()` (with salt)
+
+```solidity
+function newAuthority(address authorityOwner, uint256 epochLength, bytes32 salt) external override returns (IAuthority)
+```
+
+Deploy a new authority contract deterministically using CREATE2.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `authorityOwner` | `address` | The initial authority owner |
+| `epochLength` | `uint256` | The epoch length |
+| `salt` | `bytes32` | The salt used to deterministically generate the authority address |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `IAuthority` | The deployed authority contract |
+
+### `calculateAuthorityAddress()`
+
+```solidity
+function calculateAuthorityAddress(
+ address authorityOwner,
+ uint256 epochLength,
+ bytes32 salt
+) external view override returns (address)
+```
+
+Calculate the address of an authority to be deployed deterministically.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `authorityOwner` | `address` | The initial authority owner |
+| `epochLength` | `uint256` | The epoch length |
+| `salt` | `bytes32` | The salt used to deterministically generate the authority address |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `address` | The deterministic authority address |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/authority/authority.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/authority/authority.md
new file mode 100644
index 00000000..a2f8cf25
--- /dev/null
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/authority/authority.md
@@ -0,0 +1,87 @@
+---
+id: authority
+title: Authority
+resources:
+ - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/consensus/authority/Authority.sol
+ title: Authority Contract
+---
+
+The **Authority** contract implements a single-owner consensus mechanism where only the contract owner can submit and accept claims.
+
+## Functions
+
+### `submitClaim()`
+
+```solidity
+function submitClaim(
+ address appContract,
+ uint256 lastProcessedBlockNumber,
+ bytes32 outputsMerkleRoot
+) external onlyOwner
+```
+
+Submit a claim to the consensus. Only the contract owner can call this function.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `appContract` | `address` | The application contract address |
+| `lastProcessedBlockNumber` | `uint256` | The number of the last processed block |
+| `outputsMerkleRoot` | `bytes32` | The outputs Merkle root |
+
+### `owner()`
+
+```solidity
+function owner() public view override(IOwnable, Ownable) returns (address)
+```
+
+Returns the address of the current owner.
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `address` | The current owner address |
+
+### `renounceOwnership()`
+
+```solidity
+function renounceOwnership() public override(IOwnable, Ownable)
+```
+
+Leaves the contract without owner. It will not be possible to call onlyOwner functions.
+
+### `transferOwnership()`
+
+```solidity
+function transferOwnership(address newOwner) public override(IOwnable, Ownable)
+```
+
+Transfers ownership of the contract to a new account.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `newOwner` | `address` | The new owner address |
+
+### `supportsInterface()`
+
+```solidity
+function supportsInterface(bytes4 interfaceId) public view override(IERC165, AbstractConsensus) returns (bool)
+```
+
+Check if the contract supports a specific interface.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `interfaceId` | `bytes4` | The interface identifier |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `bool` | True if the interface is supported |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/authority/iauthority-factory.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/authority/iauthority-factory.md
new file mode 100644
index 00000000..11423631
--- /dev/null
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/authority/iauthority-factory.md
@@ -0,0 +1,96 @@
+---
+id: iauthority-factory
+title: IAuthorityFactory
+resources:
+ - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/consensus/authority/IAuthorityFactory.sol
+ title: IAuthorityFactory Interface
+---
+
+The **IAuthorityFactory** interface defines the contract for deploying new `IAuthority` contracts.
+
+## Events
+
+### `AuthorityCreated`
+
+```solidity
+event AuthorityCreated(IAuthority authority)
+```
+
+A new authority was deployed.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `authority` | `IAuthority` | The authority |
+
+## Functions
+
+### `newAuthority()`
+
+```solidity
+function newAuthority(address authorityOwner, uint256 epochLength) external returns (IAuthority)
+```
+
+Deploy a new authority.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `authorityOwner` | `address` | The initial authority owner |
+| `epochLength` | `uint256` | The epoch length |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `IAuthority` | The authority |
+
+### `newAuthority()` (with salt)
+
+```solidity
+function newAuthority(address authorityOwner, uint256 epochLength, bytes32 salt) external returns (IAuthority)
+```
+
+Deploy a new authority deterministically.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `authorityOwner` | `address` | The initial authority owner |
+| `epochLength` | `uint256` | The epoch length |
+| `salt` | `bytes32` | The salt used to deterministically generate the authority address |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `IAuthority` | The authority |
+
+### `calculateAuthorityAddress()`
+
+```solidity
+function calculateAuthorityAddress(
+ address authorityOwner,
+ uint256 epochLength,
+ bytes32 salt
+) external view returns (address)
+```
+
+Calculate the address of an authority to be deployed deterministically.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `authorityOwner` | `address` | The initial authority owner |
+| `epochLength` | `uint256` | The epoch length |
+| `salt` | `bytes32` | The salt used to deterministically generate the authority address |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `address` | The deterministic authority address |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/authority/iauthority.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/authority/iauthority.md
new file mode 100644
index 00000000..c9a2aad5
--- /dev/null
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/authority/iauthority.md
@@ -0,0 +1,19 @@
+---
+id: iauthority
+title: IAuthority
+resources:
+ - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/consensus/authority/IAuthority.sol
+ title: IAuthority Interface
+---
+
+The `IAuthority` interface defines a consensus contract controlled by a single address, the owner.
+
+## Description
+
+A consensus contract controlled by a single address, the owner. This interface combines the consensus functionality with ownership management, allowing only the owner to submit claims.
+
+## Related Contracts
+
+- [`Authority`](./authority.md): Implementation of this interface
+- [`IConsensus`](../iconsensus.md): Base consensus interface
+- [`IOwnable`](https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/access/IOwnable.sol): Ownership management interface
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/iconsensus.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/iconsensus.md
new file mode 100644
index 00000000..48348a66
--- /dev/null
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/iconsensus.md
@@ -0,0 +1,165 @@
+---
+id: iconsensus
+title: IConsensus
+resources:
+ - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/consensus/IConsensus.sol
+ title: IConsensus Interface
+---
+
+The `IConsensus` interface defines the main consensus contract behavior for validating and accepting claims submitted by validators.
+
+## Description
+
+Each application has its own stream of inputs. When an input is fed to the application, it may yield several outputs. Since genesis, a Merkle tree of all outputs ever produced is maintained both inside and outside the Cartesi Machine.
+
+The claim that validators may submit to the consensus contract is the root of this Merkle tree after processing all base layer blocks until some height.
+
+A validator should be able to save transaction fees by not submitting a claim if it was:
+- Already submitted by the validator (see the `ClaimSubmitted` event) or
+- Already accepted by the consensus (see the `ClaimAccepted` event)
+
+The acceptance criteria for claims may depend on the type of consensus, and is not specified by this interface. For example, a claim may be accepted if it was:
+- Submitted by an authority or
+- Submitted by the majority of a quorum or
+- Submitted and not proven wrong after some period of time or
+- Submitted and proven correct through an on-chain tournament
+
+## Functions
+
+### `submitClaim()`
+
+```solidity
+function submitClaim(
+ address appContract,
+ uint256 lastProcessedBlockNumber,
+ bytes32 outputsMerkleRoot
+) external
+```
+
+Submit a claim to the consensus.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `appContract` | `address` | The application contract address |
+| `lastProcessedBlockNumber` | `uint256` | The number of the last processed block |
+| `outputsMerkleRoot` | `bytes32` | The outputs Merkle root |
+
+**Events:**
+- `ClaimSubmitted`: Must be fired
+- `ClaimAccepted`: MAY be fired, if the acceptance criteria is met
+
+### `getEpochLength()`
+
+```solidity
+function getEpochLength() external view returns (uint256)
+```
+
+Get the epoch length, in number of base layer blocks.
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `uint256` | The epoch length |
+
+**Note:** The epoch number of a block is defined as the integer division of the block number by the epoch length.
+
+## Events
+
+### `ClaimSubmitted()`
+
+```solidity
+event ClaimSubmitted(
+ address indexed submitter,
+ address indexed appContract,
+ uint256 lastProcessedBlockNumber,
+ bytes32 outputsMerkleRoot
+)
+```
+
+Must trigger when a claim is submitted.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `submitter` | `address` | The submitter address |
+| `appContract` | `address` | The application contract address |
+| `lastProcessedBlockNumber` | `uint256` | The number of the last processed block |
+| `outputsMerkleRoot` | `bytes32` | The outputs Merkle root |
+
+### `ClaimAccepted()`
+
+```solidity
+event ClaimAccepted(
+ address indexed appContract,
+ uint256 lastProcessedBlockNumber,
+ bytes32 outputsMerkleRoot
+)
+```
+
+Must trigger when a claim is accepted.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `appContract` | `address` | The application contract address |
+| `lastProcessedBlockNumber` | `uint256` | The number of the last processed block |
+| `outputsMerkleRoot` | `bytes32` | The outputs Merkle root |
+
+**Note:** For each application and lastProcessedBlockNumber, there can be at most one accepted claim.
+
+## Errors
+
+### `NotEpochFinalBlock()`
+
+```solidity
+error NotEpochFinalBlock(uint256 lastProcessedBlockNumber, uint256 epochLength)
+```
+
+The claim contains the number of a block that is not at the end of an epoch (its modulo epoch length is not epoch length - 1).
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `lastProcessedBlockNumber` | `uint256` | The number of the last processed block |
+| `epochLength` | `uint256` | The epoch length |
+
+### `NotPastBlock()`
+
+```solidity
+error NotPastBlock(uint256 lastProcessedBlockNumber, uint256 currentBlockNumber)
+```
+
+The claim contains the number of a block in the future (it is greater or equal to the current block number).
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `lastProcessedBlockNumber` | `uint256` | The number of the last processed block |
+| `currentBlockNumber` | `uint256` | The number of the current block |
+
+### `NotFirstClaim()`
+
+```solidity
+error NotFirstClaim(address appContract, uint256 lastProcessedBlockNumber)
+```
+
+A claim for that application and epoch was already submitted by the validator.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `appContract` | `address` | The application contract address |
+| `lastProcessedBlockNumber` | `uint256` | The number of the last processed block |
+
+## Related Contracts
+
+- [`AbstractConsensus`](./abstract-consensus.md): Abstract implementation of this interface
+- [`IOutputsMerkleRootValidator`](./ioutputs-merkle-root-validator.md): Interface for validating outputs Merkle roots
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/ioutputs-merkle-root-validator.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/ioutputs-merkle-root-validator.md
new file mode 100644
index 00000000..2fdadf48
--- /dev/null
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/ioutputs-merkle-root-validator.md
@@ -0,0 +1,34 @@
+---
+id: ioutputs-merkle-root-validator
+title: IOutputsMerkleRootValidator
+resources:
+ - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/consensus/IOutputsMerkleRootValidator.sol
+ title: IOutputsMerkleRootValidator Interface
+---
+
+The `IOutputsMerkleRootValidator` interface provides valid outputs Merkle roots for validation.
+
+## Description
+
+This interface provides functionality to check whether an outputs Merkle root is valid. ERC-165 can be used to determine whether this contract also supports any other interface (e.g. for submitting claims).
+
+## Functions
+
+### `isOutputsMerkleRootValid`
+```solidity
+function isOutputsMerkleRootValid(address appContract, bytes32 outputsMerkleRoot) external view returns (bool)
+```
+
+Check whether an outputs Merkle root is valid.
+
+**Parameters:**
+- `appContract` (address): The application contract address
+- `outputsMerkleRoot` (bytes32): The outputs Merkle root
+
+**Returns:**
+- (bool): True if the outputs Merkle root is valid
+
+## Related Contracts
+
+- [`IConsensus`](./iconsensus.md): Interface that inherits from this interface
+- [`AbstractConsensus`](./abstract-consensus.md): Abstract implementation that implements this interface
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/overview.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/overview.md
index 4e69c587..c928237c 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/overview.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/overview.md
@@ -2,30 +2,38 @@
id: overview
title: Overview
resources:
- - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1
- title: Smart Contracts for Cartesi Rollups
+ - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/consensus
+ title: Consensus Smart Contracts
---
-The Cartesi Rollups framework consists of components on two layers: the base layer (the foundational blockchain where an application contract is deployed, such as Ethereum) and the execution layer (the Cartesi off-chain layer where the application runs its backend logic).
+The consensus mechanism in Cartesi Rollups is responsible for validating and accepting claims submitted by validators. These contracts ensure the integrity of the rollup by validating outputs Merkle roots.
-The frontend interacts with base layer smart contracts to send inputs to the backend, deposit assets, and process outputs.
+## Consensus Contracts
-To interact with an Ethereum-compatible blockchain, the application frontend must connect to a blockchain node using Ethereum's JSON-RPC API.
+The framework supports different consensus mechanisms:
-Clients can interact with Ethereum-compatible nodes using the JSON-RPC API in two ways:
+- **[Authority](./authority/authority.md)**: Single-owner consensus controlled by one address
+- **[Quorum](./quorum/quorum.md)**: Multi-validator consensus requiring majority approval
-- **Querying state (read operations)** — The state can be queried by calling functions that neither alter the blockchain state nor incur gas fees.
+## Core Interfaces
-- **Changing state (write operations)** — The state is changed by submitting a transaction that incurs gas fees. The transaction must be cryptographically signed by an Ethereum account with sufficient funds in its wallet.
+- **[IConsensus](./iconsensus.md)**: Main interface defining the consensus contract behavior
+- **[IOutputsMerkleRootValidator](./ioutputs-merkle-root-validator.md)**: Interface for validating outputs Merkle roots
+- **[AbstractConsensus](./abstract-consensus.md)**: Abstract implementation providing common consensus functionality
-## Cartesi Rollups Smart Contracts
+## Consensus Mechanism
-- [`InputBox`](../input-box.md): This contract receives inputs from users who want to interact with the off-chain layer. All inputs to your application are processed through this contract.
+A claim consists of:
-- [`Application`](../application.md): An `Application` contract is instantiated for each dApp (i.e., each dApp has its own application address). With this address, an application can hold ownership of digital assets on the base layer, such as Ether, ERC-20 tokens, and NFTs.
+- Application Contract Address: The address of the dApp being validated
+- Last Processed Block Number: The block number up to which inputs have been processed
+- Outputs Merkle Root: The root hash of the Merkle tree containing all outputs produced by the application
-- [`ApplicationFactory`](../application-factory.md): The `ApplicationFactory` contract enables anyone to deploy [`Application`](../application.md) contracts with a simple function call. It provides greater convenience to the deployer and security to users and validators, as they can verify that the bytecode has not been maliciously altered.
+The consensus contract validates that:
+- The block number is at the end of an epoch (modulo epoch length equals epoch length - 1)
+- The block number is in the past (not future)
+- No duplicate claim has been submitted for the same application and epoch
-- Portals: These contracts are used to safely transfer assets from the base layer to the execution environment of your application. Currently, Portal contracts are available for the following types of assets: [Ether (ETH)](../portals/EtherPortal.md), [ERC-20 (Fungible tokens)](../portals/ERC20Portal.md), [ERC-721 (Non-fungible tokens)](../portals/ERC721Portal.md), [ERC-1155 single transfer](../portals/ERC1155SinglePortal.md), and [ERC-1155 batch token transfers](../portals/ERC1155BatchPortal.md).
+Once a claim is accepted, the outputs Merkle root becomes valid and can be used to validate individual outputs in the application contract.
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/quorum/iquorum-factory.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/quorum/iquorum-factory.md
new file mode 100644
index 00000000..b4c12d3d
--- /dev/null
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/quorum/iquorum-factory.md
@@ -0,0 +1,96 @@
+---
+id: iquorum-factory
+title: IQuorumFactory
+resources:
+ - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/consensus/quorum/IQuorumFactory.sol
+ title: IQuorumFactory Interface
+---
+
+The **IQuorumFactory** interface defines the contract for deploying new `IQuorum` contracts.
+
+## Events
+
+### `QuorumCreated`
+
+```solidity
+event QuorumCreated(IQuorum quorum)
+```
+
+A new quorum was deployed.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `quorum` | `IQuorum` | The quorum |
+
+## Functions
+
+### `newQuorum()`
+
+```solidity
+function newQuorum(address[] calldata validators, uint256 epochLength) external returns (IQuorum)
+```
+
+Deploy a new quorum.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `validators` | `address[]` | The list of validators |
+| `epochLength` | `uint256` | The epoch length |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `IQuorum` | The quorum |
+
+### `newQuorum()` (with salt)
+
+```solidity
+function newQuorum(address[] calldata validators, uint256 epochLength, bytes32 salt) external returns (IQuorum)
+```
+
+Deploy a new quorum deterministically.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `validators` | `address[]` | The list of validators |
+| `epochLength` | `uint256` | The epoch length |
+| `salt` | `bytes32` | The salt used to deterministically generate the quorum address |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `IQuorum` | The quorum |
+
+### `calculateQuorumAddress()`
+
+```solidity
+function calculateQuorumAddress(
+ address[] calldata validators,
+ uint256 epochLength,
+ bytes32 salt
+) external view returns (address)
+```
+
+Calculate the address of a quorum to be deployed deterministically.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `validators` | `address[]` | The list of validators |
+| `epochLength` | `uint256` | The epoch length |
+| `salt` | `bytes32` | The salt used to deterministically generate the quorum address |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `address` | The deterministic quorum address |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/quorum/iquorum.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/quorum/iquorum.md
new file mode 100644
index 00000000..660e317e
--- /dev/null
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/quorum/iquorum.md
@@ -0,0 +1,140 @@
+---
+id: iquorum
+title: IQuorum
+resources:
+ - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/consensus/quorum/IQuorum.sol
+ title: IQuorum Interface
+---
+
+The `IQuorum` interface defines a consensus model controlled by a small, immutable set of validators.
+
+## Description
+
+A consensus model controlled by a small, immutable set of `n` validators. You can know the value of `n` by calling the `numOfValidators` function. Upon construction, each validator is assigned a unique number between 1 and `n`. These numbers are used internally instead of addresses for gas optimization reasons. You can list the validators in the quorum by calling the `validatorById` function for each ID from 1 to `n`.
+
+## Functions
+
+### `numOfValidators`
+```solidity
+function numOfValidators() external view returns (uint256)
+```
+
+Get the number of validators.
+
+**Returns:**
+- (uint256): The total number of validators
+
+### `validatorId`
+```solidity
+function validatorId(address validator) external view returns (uint256)
+```
+
+Get the ID of a validator.
+
+**Parameters:**
+- `validator` (address): The validator address
+
+**Returns:**
+- (uint256): The validator ID
+
+**Note:** Validators have IDs greater than zero. Non-validators are assigned to ID zero.
+
+### `validatorById`
+```solidity
+function validatorById(uint256 id) external view returns (address)
+```
+
+Get the address of a validator by its ID.
+
+**Parameters:**
+- `id` (uint256): The validator ID
+
+**Returns:**
+- (address): The validator address
+
+**Note:** Validator IDs range from 1 to `N`, the total number of validators. Invalid IDs map to address zero.
+
+### `numOfValidatorsInFavorOfAnyClaimInEpoch`
+```solidity
+function numOfValidatorsInFavorOfAnyClaimInEpoch(
+ address appContract,
+ uint256 lastProcessedBlockNumber
+) external view returns (uint256)
+```
+
+Get the number of validators in favor of any claim in a given epoch.
+
+**Parameters:**
+- `appContract` (address): The application contract address
+- `lastProcessedBlockNumber` (uint256): The number of the last processed block
+
+**Returns:**
+- (uint256): Number of validators in favor of any claim in the epoch
+
+### `isValidatorInFavorOfAnyClaimInEpoch`
+```solidity
+function isValidatorInFavorOfAnyClaimInEpoch(
+ address appContract,
+ uint256 lastProcessedBlockNumber,
+ uint256 id
+) external view returns (bool)
+```
+
+Check whether a validator is in favor of any claim in a given epoch.
+
+**Parameters:**
+- `appContract` (address): The application contract address
+- `lastProcessedBlockNumber` (uint256): The number of the last processed block
+- `id` (uint256): The ID of the validator
+
+**Returns:**
+- (bool): Whether validator is in favor of any claim in the epoch
+
+**Note:** Assumes the provided ID is valid.
+
+### `numOfValidatorsInFavorOf`
+```solidity
+function numOfValidatorsInFavorOf(
+ address appContract,
+ uint256 lastProcessedBlockNumber,
+ bytes32 outputsMerkleRoot
+) external view returns (uint256)
+```
+
+Get the number of validators in favor of a claim.
+
+**Parameters:**
+- `appContract` (address): The application contract address
+- `lastProcessedBlockNumber` (uint256): The number of the last processed block
+- `outputsMerkleRoot` (bytes32): The outputs Merkle root
+
+**Returns:**
+- (uint256): Number of validators in favor of claim
+
+### `isValidatorInFavorOf`
+```solidity
+function isValidatorInFavorOf(
+ address appContract,
+ uint256 lastProcessedBlockNumber,
+ bytes32 outputsMerkleRoot,
+ uint256 id
+) external view returns (bool)
+```
+
+Check whether a validator is in favor of a claim.
+
+**Parameters:**
+- `appContract` (address): The application contract address
+- `lastProcessedBlockNumber` (uint256): The number of the last processed block
+- `outputsMerkleRoot` (bytes32): The outputs Merkle root
+- `id` (uint256): The ID of the validator
+
+**Returns:**
+- (bool): Whether validator is in favor of claim
+
+**Note:** Assumes the provided ID is valid.
+
+## Related Contracts
+
+- [`Quorum`](./quorum.md): Implementation of this interface
+- [`IConsensus`](../iconsensus.md): Base consensus interface
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/quorum/quorum-factory.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/quorum/quorum-factory.md
new file mode 100644
index 00000000..4f0d09e6
--- /dev/null
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/quorum/quorum-factory.md
@@ -0,0 +1,80 @@
+---
+id: quorum-factory
+title: QuorumFactory
+resources:
+ - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/consensus/quorum/QuorumFactory.sol
+ title: QuorumFactory Contract
+---
+
+The **QuorumFactory** contract allows anyone to reliably deploy new `IQuorum` contracts.
+
+## Functions
+
+### `newQuorum()`
+
+```solidity
+function newQuorum(address[] calldata validators, uint256 epochLength) external override returns (IQuorum)
+```
+
+Deploy a new quorum contract.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `validators` | `address[]` | The list of validators |
+| `epochLength` | `uint256` | The epoch length |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `IQuorum` | The deployed quorum contract |
+
+### `newQuorum()` (with salt)
+
+```solidity
+function newQuorum(address[] calldata validators, uint256 epochLength, bytes32 salt) external override returns (IQuorum)
+```
+
+Deploy a new quorum contract deterministically using CREATE2.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `validators` | `address[]` | The list of validators |
+| `epochLength` | `uint256` | The epoch length |
+| `salt` | `bytes32` | The salt used to deterministically generate the quorum address |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `IQuorum` | The deployed quorum contract |
+
+### `calculateQuorumAddress()`
+
+```solidity
+function calculateQuorumAddress(
+ address[] calldata validators,
+ uint256 epochLength,
+ bytes32 salt
+) external view override returns (address)
+```
+
+Calculate the address of a quorum to be deployed deterministically.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `validators` | `address[]` | The list of validators |
+| `epochLength` | `uint256` | The epoch length |
+| `salt` | `bytes32` | The salt used to deterministically generate the quorum address |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `address` | The deterministic quorum address |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/quorum/quorum.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/quorum/quorum.md
new file mode 100644
index 00000000..0842e4f0
--- /dev/null
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/consensus/quorum/quorum.md
@@ -0,0 +1,209 @@
+---
+id: quorum
+title: Quorum
+resources:
+ - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/consensus/quorum/Quorum.sol
+ title: Quorum Contract
+---
+
+The **Quorum** contract implements a multi-validator consensus mechanism where claims are accepted when a majority of validators vote in favor.
+
+## Functions
+
+### `submitClaim()`
+
+```solidity
+function submitClaim(
+ address appContract,
+ uint256 lastProcessedBlockNumber,
+ bytes32 outputsMerkleRoot
+) external override
+```
+
+Submit a claim to the consensus. Only validators can call this function.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `appContract` | `address` | The application contract address |
+| `lastProcessedBlockNumber` | `uint256` | The number of the last processed block |
+| `outputsMerkleRoot` | `bytes32` | The outputs Merkle root |
+
+### `numOfValidators()`
+
+```solidity
+function numOfValidators() external view override returns (uint256)
+```
+
+Get the number of validators.
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `uint256` | The total number of validators |
+
+### `validatorId()`
+
+```solidity
+function validatorId(address validator) external view override returns (uint256)
+```
+
+Get the ID of a validator.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `validator` | `address` | The validator address |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `uint256` | The validator ID (0 for non-validators, >0 for validators) |
+
+### `validatorById()`
+
+```solidity
+function validatorById(uint256 id) external view override returns (address)
+```
+
+Get the address of a validator by its ID.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `id` | `uint256` | The validator ID |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `address` | The validator address (address(0) for invalid IDs) |
+
+### `numOfValidatorsInFavorOfAnyClaimInEpoch()`
+
+```solidity
+function numOfValidatorsInFavorOfAnyClaimInEpoch(
+ address appContract,
+ uint256 lastProcessedBlockNumber
+) external view override returns (uint256)
+```
+
+Get the number of validators in favor of any claim in a given epoch.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `appContract` | `address` | The application contract address |
+| `lastProcessedBlockNumber` | `uint256` | The number of the last processed block |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `uint256` | Number of validators in favor of any claim in the epoch |
+
+### `isValidatorInFavorOfAnyClaimInEpoch()`
+
+```solidity
+function isValidatorInFavorOfAnyClaimInEpoch(
+ address appContract,
+ uint256 lastProcessedBlockNumber,
+ uint256 id
+) external view override returns (bool)
+```
+
+Check whether a validator is in favor of any claim in a given epoch.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `appContract` | `address` | The application contract address |
+| `lastProcessedBlockNumber` | `uint256` | The number of the last processed block |
+| `id` | `uint256` | The ID of the validator |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `bool` | Whether validator is in favor of any claim in the epoch |
+
+### `numOfValidatorsInFavorOf()`
+
+```solidity
+function numOfValidatorsInFavorOf(
+ address appContract,
+ uint256 lastProcessedBlockNumber,
+ bytes32 outputsMerkleRoot
+) external view override returns (uint256)
+```
+
+Get the number of validators in favor of a claim.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `appContract` | `address` | The application contract address |
+| `lastProcessedBlockNumber` | `uint256` | The number of the last processed block |
+| `outputsMerkleRoot` | `bytes32` | The outputs Merkle root |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `uint256` | Number of validators in favor of claim |
+
+### `isValidatorInFavorOf()`
+
+```solidity
+function isValidatorInFavorOf(
+ address appContract,
+ uint256 lastProcessedBlockNumber,
+ bytes32 outputsMerkleRoot,
+ uint256 id
+) external view override returns (bool)
+```
+
+Check whether a validator is in favor of a claim.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `appContract` | `address` | The application contract address |
+| `lastProcessedBlockNumber` | `uint256` | The number of the last processed block |
+| `outputsMerkleRoot` | `bytes32` | The outputs Merkle root |
+| `id` | `uint256` | The ID of the validator |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `bool` | Whether validator is in favor of claim |
+
+### `supportsInterface()`
+
+```solidity
+function supportsInterface(bytes4 interfaceId) public view override(IERC165, AbstractConsensus) returns (bool)
+```
+
+Check if the contract supports a specific interface.
+
+**Parameters**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `interfaceId` | `bytes4` | The interface identifier |
+
+**Return Values**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `[0]` | `bool` | True if the interface is supported |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/input-box.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/input-box.md
index d5cd8e3f..db3db8c7 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/input-box.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/input-box.md
@@ -2,132 +2,99 @@
id: input-box
title: InputBox
resources:
- - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/inputs/InputBox.sol
+ - url: https://github.com/cartesi/rollups-contracts/tree/prerelease/2.0.0/contracts/inputs/InputBox.sol
title: InputBox contract
---
-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 **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").
-The hash stored on-chain comprises the hash of the input blob, block number, timestamp, input sender address, and input index.
+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 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.
+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 this contract's perspective, inputs are encoding-agnostic byte arrays. It is the application's responsibility to interpret, validate, and act upon these inputs.
+From the perspective of this contract, inputs are encoding-agnostic byte arrays. It is up to the application to interpret, validate, and act upon inputs.
-This contract inherits from `IInputBox`.
-## State Variables
-
-### `_deploymentBlockNumber`
-Deployment block number
+## `InputAdded()`
```solidity
-uint256 immutable _deploymentBlockNumber = block.number;
+event InputAdded(address indexed appContract, uint256 indexed index, bytes input)
```
-### `_inputBoxes`
-Mapping of application contract addresses to arrays of input hashes.
+Emitted when an input is added to an application's input box.
-```solidity
-mapping(address => bytes32[]) private _inputBoxes;
-```
+#### Parameters
-## Functions
+| Name | Type | Description |
+|-------------|----------|----------------------------------|
+| appContract | address | The application contract address |
+| index | uint256 | The input index |
+| input | bytes | The input blob |
-### `addInput()`
+## `addInput()`
```solidity
function addInput(address appContract, bytes calldata payload) external override returns (bytes32)
```
-Send an input to an application.
+Add an input to an application's input box.
-*MUST fire an InputAdded event.*
+_MUST fire an `InputAdded` event accordingly._
-**Parameters**
+#### Parameters
-| Name | Type | Description |
-|------|------|-------------|
-| `appContract` | `address` | The application contract address |
-| `payload` | `bytes` | The input payload |
+| Name | Type | Description |
+|-------------|----------|----------------------------------|
+| appContract | address | The application contract address |
+| payload | bytes | The input payload |
-**Return Values**
+#### Return Values
-| Name | Type | Description |
-|------|------|-------------|
-| `[0]` | `bytes32` | The hash of the input blob |
+| Name | Type | Description |
+|--------|----------|------------------------------|
+| [0] | bytes32 | The hash of the input blob |
-### `getNumberOfInputs()`
+## `getNumberOfInputs()`
```solidity
-function getNumberOfInputs(address appContract) external view override returns (uint256)
+function getNumberOfInputs(address appContract) external view returns (uint256)
```
-Get the number of inputs sent to an application.
-
-**Parameters**
+Get the number of inputs in an application's input box.
-| Name | Type | Description |
-|------|------|-------------|
-| `appContract` | `address` | The application contract address |
+#### Parameters
-**Return Values**
+| Name | Type | Description |
+|-------------|----------|----------------------------------|
+| appContract | address | The application contract address |
-| Name | Type | Description |
-|------|------|-------------|
-| `[0]` | `uint256` | Number of inputs in the application input box |
-
-### `getInputHash()`
-
-```solidity
-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.*
+#### Return Values
-**Parameters**
+| Name | Type | Description |
+| ---- | ------- | ---------------------------------------- |
+| [0] | uint256 | Number of inputs in the application input box |
-| Name | Type | Description |
-|------|------|-------------|
-| `appContract` | `address` | The application contract address |
-| `index` | `uint256` | The input index |
-
-**Return Values**
-
-| Name | Type | Description |
-|------|------|-------------|
-| `[0]` | `bytes32` | The hash of the input at the provided index in the application input box |
-
-### `getDeploymentBlockNumber()`
+## `getInputHash()`
```solidity
-function getDeploymentBlockNumber() external view override returns (uint256)
+function getInputHash(address appContract, uint256 index) external view returns (bytes32)
```
-Get number of block in which contract was deployed.
-
-**Return Values**
-
-| Name | Type | Description |
-|------|------|-------------|
-| `[0]` | `uint256` | The deployment block number |
-
-## Events
+Get the hash of an input in an application's input box.
-### `InputAdded()`
+`index` MUST be in the interval `[0,n)` where `n` is the number of
+inputs in the application input box. See the `getNumberOfInputs` function._
-```solidity
-event InputAdded(address indexed appContract, uint256 indexed index, bytes input)
-```
+#### Parameters
-Emitted when an input is added to an application's input box.
+| Name | Type | Description |
+|-------------|----------|----------------------------------|
+| appContract | address | The application contract address |
+| index | uint256 | The input index |
-**Parameters**
+#### Return Values
-| Name | Type | Description |
-|------|------|-------------|
-| `appContract` | `address` | The application contract address |
-| `index` | `uint256` | The input index |
-| `input` | `bytes` | The input blob |
\ No newline at end of file
+| Name | Type | Description |
+| ---- | ------- | ------------------------------------------------------------------- |
+| [0] | bytes32 | The hash of the input at the provided index in the application input box |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/overview.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/overview.md
index ce2566da..d2a72352 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/overview.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/overview.md
@@ -2,30 +2,30 @@
id: overview
title: Overview
resources:
- - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1
+ - url: https://github.com/cartesi/rollups-contracts/tree/prerelease/2.0.0/contracts
title: Smart Contracts for Cartesi Rollups
---
-The Cartesi Rollups framework consists of components on two layers: the base layer (the foundational blockchain where an application contract is deployed, such as Ethereum) and the execution layer (the Cartesi off-chain layer where the application runs its backend logic).
+The Cartesi Rollups framework consists of components on the base layer (the foundational blockchain where an application contract is deployed, such as Ethereum) and the execution layer (the Cartesi off-chain layer where the application runs its backend logic).
The frontend interacts with base layer smart contracts to send inputs to the backend, deposit assets, and process outputs.
To interact with an Ethereum-compatible blockchain, the application frontend must connect to a blockchain node using Ethereum's JSON-RPC API.
-Clients can interact with Ethereum-compatible nodes using the JSON-RPC API in two ways:
+There are two ways in which clients can interact with Ethereum-compatible nodes using the JSON-RPC API:
-- **Querying state (read operations)** — The state can be queried by calling functions that neither alter the blockchain state nor incur gas fees.
+- **Querying state (read operations)** — The state can be queried by calling functions that do not alter the blockchain state or incur gas fees.
-- **Changing state (write operations)** — The state is changed by submitting a transaction that incurs gas fees. The transaction must be cryptographically signed by an Ethereum account with sufficient funds in its wallet.
+- **Changing state (write operations)** — The state is changed by submitting a transaction, which incurs gas fees. The transaction must be cryptographically signed by an Ethereum account with funds in its wallet.
## Cartesi Rollups Smart Contracts
-- [`InputBox`](../contracts/input-box.md): This contract receives inputs from users who want to interact with the off-chain layer. All inputs to your application are processed through this contract.
+- [`InputBox`](../contracts/input-box.md): This contract receives inputs from users who want to interact with the off-chain layer. All inputs to your application go through this contract.
-- [`Application`](../contracts/application.md): An `Application` contract is instantiated for each dApp (i.e., each dApp has its own application address). With this address, an application can hold ownership of digital assets on the base layer, such as Ether, ERC-20 tokens, and NFTs.
+- [`Application`](../contracts/application.md): This `Application` contract is instantiated for each dApp (i.e., each dApp has its application address). With this address, an application can hold ownership over digital assets on the base layer, like Ether, ERC-20 tokens, and NFTs.
-- [`ApplicationFactory`](../contracts/application-factory.md): The `ApplicationFactory` contract enables anyone to deploy [`Application`](../contracts/application.md) contracts with a simple function call. It provides greater convenience to the deployer and security to users and validators, as they can verify that the bytecode has not been maliciously altered.
+- [`ApplicationFactory`](../contracts/application-factory.md): The `ApplicationFactory` contract allows anyone to deploy [`Application`](../contracts/application.md) contracts with a simple function call. It provides greater convenience to the deployer and security to users and validators, as they know the bytecode could not have been altered maliciously.
-- Portals: These contracts are used to safely transfer assets from the base layer to the execution environment of your application. Currently, Portal contracts are available for the following types of assets: [Ether (ETH)](../contracts/portals/EtherPortal.md), [ERC-20 (Fungible tokens)](../contracts/portals/ERC20Portal.md), [ERC-721 (Non-fungible tokens)](../contracts/portals/ERC721Portal.md), [ERC-1155 single transfer](../contracts/portals/ERC1155SinglePortal.md), and [ERC-1155 batch token transfers](../contracts/portals/ERC1155BatchPortal.md).
+- Portals: These are a set of contracts used to safely teleport assets from the base layer to the execution environment of your application. Currently, there are Portal contracts for the following types of assets: [Ether (ETH)](../contracts/portals/EtherPortal.md), [ERC-20 (Fungible tokens)](../contracts/portals/ERC20Portal.md), [ERC-721 (Non-fungible tokens)](../contracts/portals/ERC721Portal.md), [ERC-1155 single transfer](../contracts/portals/ERC1155SinglePortal.md) and [ERC-1155 batch token transfers](../contracts/portals/ERC1155BatchPortal.md).
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC1155BatchPortal.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC1155BatchPortal.md
index 6426db55..e91d657d 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC1155BatchPortal.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC1155BatchPortal.md
@@ -1,6 +1,6 @@
---
resources:
- - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/portals/ERC1155BatchPortal.sol
+ - url: https://github.com/cartesi/rollups-contracts/blob/v1.4.0/onchain/rollups/contracts/portals/ERC1155BatchPortal.sol
title: ERC1155BatchPortal contract
---
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC1155SinglePortal.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC1155SinglePortal.md
index 95dda15a..ad41581a 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC1155SinglePortal.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC1155SinglePortal.md
@@ -1,6 +1,6 @@
---
resources:
- - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/portals/ERC1155SinglePortal.sol
+ - url: https://github.com/cartesi/rollups-contracts/blob/v1.4.0/onchain/rollups/contracts/portals/ERC1155SinglePortal.sol
title: ERC1155SinglePortal contract
---
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC20Portal.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC20Portal.md
index df75ab82..ded704b1 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC20Portal.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC20Portal.md
@@ -1,6 +1,6 @@
---
resources:
- - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/portals/ERC20Portal.sol
+ - url: https://github.com/cartesi/rollups-contracts/blob/v1.4.0/onchain/rollups/contracts/portals/ERC20Portal.sol
title: ERC20Portal contract
---
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC721Portal.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC721Portal.md
index abf53dcb..443f7cd5 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC721Portal.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/ERC721Portal.md
@@ -1,6 +1,6 @@
---
resources:
- - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/portals/ERC721Portal.sol
+ - url: https://github.com/cartesi/rollups-contracts/blob/v1.4.0/onchain/rollups/contracts/portals/ERC721Portal.sol
title: ERC721Portal contract
---
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/EtherPortal.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/EtherPortal.md
index 73b58ebf..a39cb8c4 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/EtherPortal.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/portals/EtherPortal.md
@@ -1,6 +1,6 @@
---
resources:
- - url: https://github.com/cartesi/rollups-contracts/tree/v2.0.1/src/contracts/portals/EtherPortal.sol
+ - url: https://github.com/cartesi/rollups-contracts/blob/v1.2.0/onchain/rollups/contracts/portals/EtherPortal.sol
title: EtherPortal contract
---
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/inputs/_category_.yml b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/inputs/_category_.yml
new file mode 100644
index 00000000..9faf3ac0
--- /dev/null
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/inputs/_category_.yml
@@ -0,0 +1,2 @@
+label: Inputs
+link: null
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/inputs/input-filter.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/inputs/input-filter.md
new file mode 100644
index 00000000..8193e1c0
--- /dev/null
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/inputs/input-filter.md
@@ -0,0 +1,25 @@
+---
+id: input-filter
+title: InputFilter
+hide_table_of_contents: false
+---
+
+
+Filter object to restrict results depending on input properties
+
+```graphql
+input InputFilter {
+ indexLowerThan: Int
+ indexGreaterThan: Int
+}
+```
+
+
+## Fields
+
+| Name | Type | Description |
+| ---- |------| ------|
+| `indexLowerThan` | [`Int`](../../scalars/int) | Filter only inputs with index lower than a given value |
+| `indexGreaterThan` | [`Int`](../../scalars/int) | Filter only inputs with index greater than a given value |
+
+
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-connection.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-connection.md
index cabf1f83..f0920851 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-connection.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-connection.md
@@ -4,15 +4,12 @@ title: InputConnection
hide_table_of_contents: false
---
-Represents a paginated list of inputs.
+
+Represents a paginated connection of Inputs.
```graphql
type InputConnection {
- "Total number of entries that match the query"
- totalCount: Int!
- "List of edges in the connection"
edges: [InputEdge!]!
- "Information about the current page"
pageInfo: PageInfo!
}
```
@@ -20,33 +17,10 @@ type InputConnection {
## Fields
| Name | Type | Description |
-| ---- |------| ----------- |
-| `totalCount` | [`Int!`](../../scalars/int) | Total number of entries that match the query. |
-| `edges` | [`[InputEdge!]!`](../../objects/input-edge) | List of edges in the connection. |
-| `pageInfo` | [`PageInfo!`](../../objects/page-info) | Information about the current page. |
+| ---- |------| ------|
+| `edges`| [`InputEdge`](../../objects/input-edge) | A list of `InputEdge` objects. Each edge contains an `Input` object and a cursor for pagination. |
+| `pageInfo`| [`PageInfo`](../../objects/page-info) | Metadata about the pagination. |
+
+
-## Example Query
-```graphql
-query {
- inputs(first: 10) {
- totalCount
- edges {
- node {
- id
- index
- status
- msgSender
- payload
- }
- cursor
- }
- pageInfo {
- hasNextPage
- hasPreviousPage
- startCursor
- endCursor
- }
- }
-}
-```
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-edge.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-edge.md
index 2f500b71..c757528a 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-edge.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-edge.md
@@ -4,39 +4,24 @@ title: InputEdge
hide_table_of_contents: false
---
-Represents a single input in a paginated list.
+
+Pagination entry.
```graphql
type InputEdge {
- "The input at this edge"
node: Input!
- "A cursor for use in pagination"
cursor: String!
}
```
+
## Fields
| Name | Type | Description |
-| ---- |------| ----------- |
-| `node` | [`Input!`](../../objects/input) | The input at this edge. |
-| `cursor` | [`String!`](../../scalars/string) | A cursor for use in pagination. |
+| ---- | ---- | ----------- |
+| `node` | [`Input!`](../../objects/input) | The Input object. |
+| `cursor` | [`String!`](../../scalars/string) | A string that serves as a pagination cursor for this particular edge. |
+
+
-## Example Query
-```graphql
-query {
- inputs(first: 10) {
- edges {
- node {
- id
- index
- status
- msgSender
- payload
- }
- cursor
- }
- }
-}
-```
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input.md
index a04ba1cf..49e0ac9b 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input.md
@@ -4,119 +4,36 @@ title: Input
hide_table_of_contents: false
---
-Request submitted to the application to advance its state.
+
+Request submitted to the application to advance its state
```graphql
type Input {
- "id of the input"
- id: String!
- "Input index starting from genesis"
index: Int!
- "Status of the input"
status: CompletionStatus!
- "Address responsible for submitting the input"
+ timestamp: DateTime!
msgSender: String!
- "Timestamp associated with the input submission, as defined by the base layer's block in which it was recorded"
- timestamp: BigInt! @deprecated(reason: "Use `blockTimestamp` instead")
- "Number of the base layer block in which the input was recorded"
- blockNumber: BigInt!
- "Input payload in Ethereum hex binary format, starting with '0x'"
+ blockNumber: Int!
payload: String!
- "Get vouchers from this particular input with support for pagination"
- vouchers(first: Int, last: Int, after: String, before: String): VoucherConnection!
- "Get DELEGATECALL vouchers from this particular input with support for pagination"
- delegateCallVouchers(first: Int, last: Int, after: String, before: String): DelegateCallVoucherConnection!
- "Get notices from this particular input with support for pagination"
- notices(first: Int, last: Int, after: String, before: String): NoticeConnection!
- "Get reports from this particular input with support for pagination"
- reports(first: Int, last: Int, after: String, before: String): ReportConnection!
- "Timestamp associated with the Espresso input submission"
- espressoTimestamp: String @deprecated(reason: "Will be removed")
- "Number of the Espresso block in which the input was recorded"
- espressoBlockNumber: String @deprecated(reason: "Will be removed")
- "Input index in the Input Box"
- inputBoxIndex: String
- "Block timestamp"
- blockTimestamp: BigInt
- "Previous RANDAO value"
- prevRandao: String
- "The application that produced the input"
- application: Application!
+ notices: NoticeConnection!
+ vouchers: VoucherConnection!
+ reports: ReportConnection!
}
```
-## Fields
+### Fields
| Name | Type | Description |
-| ---- |------| ----------- |
-| `id` | [`String!`](../../scalars/string) | ID of the input. |
-| `index` | [`Int!`](../../scalars/int) | Input index starting from genesis. |
-| `status` | [`CompletionStatus!`](../../enums/completion-status) | Status of the input. |
-| `msgSender` | [`String!`](../../scalars/string) | Address responsible for submitting the input. |
-| `timestamp` | [`BigInt!`](../../scalars/bigint) | Timestamp associated with the input submission, as defined by the base layer's block in which it was recorded. |
-| `blockNumber` | [`BigInt!`](../../scalars/bigint) | Number of the base layer block in which the input was recorded. |
-| `payload` | [`String!`](../../scalars/string) | Input payload in Ethereum hex binary format, starting with '0x'. |
-| `vouchers` | [`VoucherConnection!`](../../objects/voucher-connection) | Get vouchers from this particular input with support for pagination. |
-| `delegateCallVouchers` | [`DelegateCallVoucherConnection!`](../../objects/delegate-call-voucher-connection) | Get DELEGATECALL vouchers from this particular input with support for pagination. |
-| `notices` | [`NoticeConnection!`](../../objects/notice-connection) | Get notices from this particular input with support for pagination. |
-| `reports` | [`ReportConnection!`](../../objects/report-connection) | Get reports from this particular input with support for pagination. |
-| `espressoTimestamp` | [`String`](../../scalars/string) | Timestamp associated with the Espresso input submission. |
-| `espressoBlockNumber` | [`String`](../../scalars/string) | Number of the Espresso block in which the input was recorded. |
-| `inputBoxIndex` | [`String`](../../scalars/string) | Input index in the Input Box. |
-| `blockTimestamp` | [`BigInt`](../../scalars/bigint) | Block timestamp. |
-| `prevRandao` | [`String`](../../scalars/string) | Previous RANDAO value. |
-| `application` | [`Application!`](../../objects/application) | The application that produced the input. |
+| ---- | ---- | ----------- |
+| `index` | [`Int!`](../../scalars/int) | Unique identifier for the input. |
+| `status` | [`CompletionStatus!`](../../objects/completion-status) | Current status of the input processing. |
+| `timestamp` | [`DateTime!`](../../scalars/date-time) | Timestamp associated with the input submission. |
+| `msgSender` | [`String!`](../../scalars/string) | Address of the account that submitted the input. |
+| `blockNumber` | [`Int!`](../../scalars/int) | Number of the base layer block in which the input was recorded. |
+| `payload` | [`String!`](../../scalars/string) | The actual data/content of the input. |
+| `notices` | [`NoticeConnection!`](../../objects/notice-connection) | List of notices associated with this input. |
+| `vouchers` | [`VoucherConnection!`](../../objects/voucher-connection) | List of vouchers associated with this input. |
+| `reports` | [`ReportConnection!`](../../objects/report-connection) | List of reports associated with this input. |
+
-## Example Query
-```graphql
-query {
- input(outputIndex: 1) {
- id
- index
- status
- msgSender
- timestamp
- blockNumber
- payload
- vouchers(first: 10) {
- edges {
- node {
- index
- destination
- payload
- }
- }
- }
- delegateCallVouchers(first: 10) {
- edges {
- node {
- index
- destination
- payload
- }
- }
- }
- notices(first: 10) {
- edges {
- node {
- index
- payload
- }
- }
- }
- reports(first: 10) {
- edges {
- node {
- index
- payload
- }
- }
- }
- application {
- address
- name
- }
- }
-}
-```
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-connection.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-connection.md
index 4e6117cd..7bdf6b88 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-connection.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-connection.md
@@ -4,15 +4,12 @@ title: NoticeConnection
hide_table_of_contents: false
---
-Represents a paginated list of notices.
+
+Represents a paginated connection of Notices.
```graphql
type NoticeConnection {
- "Total number of entries that match the query"
- totalCount: Int!
- "List of edges in the connection"
edges: [NoticeEdge!]!
- "Information about the current page"
pageInfo: PageInfo!
}
```
@@ -20,34 +17,11 @@ type NoticeConnection {
## Fields
| Name | Type | Description |
-| ---- |------| ----------- |
-| `totalCount` | [`Int!`](../../scalars/int) | Total number of entries that match the query. |
-| `edges` | [`[NoticeEdge!]!`](../../objects/notice-edge) | List of edges in the connection. |
-| `pageInfo` | [`PageInfo!`](../../objects/page-info) | Information about the current page. |
+| ---- |------| ------|
+| `edges`| [`NoticeEdge`](../../objects/notice-edge) | A list of `Notice` objects. Each edge contains a `Notice` object and a cursor for pagination. |
+| `pageInfo`| [`PageInfo`](../../objects/page-info) | Metadata about the pagination. |
+
+
+
-## Example Query
-```graphql
-query {
- notices(first: 10) {
- totalCount
- edges {
- node {
- index
- payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- }
- cursor
- }
- pageInfo {
- hasNextPage
- hasPreviousPage
- startCursor
- endCursor
- }
- }
-}
-```
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-edge.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-edge.md
index 63188fb6..09af6d6a 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-edge.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-edge.md
@@ -4,13 +4,12 @@ title: NoticeEdge
hide_table_of_contents: false
---
-Represents a single notice in a paginated list.
+
+Pagination entry
```graphql
type NoticeEdge {
- "The notice at this edge"
node: Notice!
- "A cursor for use in pagination"
cursor: String!
}
```
@@ -18,26 +17,11 @@ type NoticeEdge {
## Fields
| Name | Type | Description |
-| ---- |------| ----------- |
-| `node` | [`Notice!`](../../objects/notice) | The notice at this edge. |
-| `cursor` | [`String!`](../../scalars/string) | A cursor for use in pagination. |
+| ---- | ---- | ----------- |
+| `node` | [`Notice!`](../../objects/notice) | The Notice object. |
+| `cursor` | [`String!`](../../scalars/string) | A string that serves as a pagination cursor for this particular edge. |
+
+
+
-## Example Query
-```graphql
-query {
- notices(first: 10) {
- edges {
- node {
- index
- payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- }
- cursor
- }
- }
-}
-```
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice.md
index 165b9566..1bc7bf07 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice.md
@@ -4,51 +4,30 @@ title: Notice
hide_table_of_contents: false
---
+
Informational statement that can be validated in the base layer blockchain.
```graphql
type Notice {
- "Notice index within the context of the input that produced it"
index: Int!
- "Input whose processing produced the notice"
input: Input!
- "Notice data as a payload in Ethereum hex binary format, starting with '0x'"
payload: String!
- "Proof object that allows this notice to be validated by the base layer blockchain"
proof: Proof
- "The application that produced the notice"
- application: Application!
}
```
+
## Fields
| Name | Type | Description |
| ---- |------| ----------- |
-| `index` | [`Int!`](../../scalars/int) | Notice index within the context of the input that produced it. |
-| `input` | [`Input!`](../../objects/input) | Input whose processing produced the notice. |
-| `payload` | [`String!`](../../scalars/string) | Notice data as a payload in Ethereum hex binary format, starting with '0x'. |
-| `proof` | [`Proof`](../../objects/proof) | Proof object that allows this notice to be validated by the base layer blockchain. |
-| `application` | [`Application!`](../../objects/application) | The application that produced the notice. |
+| `index`| [`Int!`](../../scalars/int) | Unique identifier for the notice. |
+| `input`| [`Input!`](../../objects/input) | The input associated with this notice. |
+| `payload`| [`String!`](../../scalars/string) |The actual data/content of the notice. |
+| `proof`| [`Proof`](../../objects/proof) | Proof of the notice's validity (if available). |
+
+
+
+
-## Example Query
-```graphql
-query {
- notice(outputIndex: 1) {
- index
- input {
- index
- }
- payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- application {
- address
- name
- }
- }
-}
-```
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/proof.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/proof.md
index 57f3f671..2f96f7dd 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/proof.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/proof.md
@@ -4,33 +4,24 @@ title: Proof
hide_table_of_contents: false
---
-Data that can be used as proof to validate notices and execute vouchers on the base layer blockchain.
+Represents the proof of validity for a notice or voucher.
```graphql
type Proof {
- "Index of the output in the output box"
- outputIndex: BigInt!
- "Array of sibling hashes in the output box merkle tree"
- outputHashesSiblings: [String]!
+ validity: OutputValidityProof!
+ context: String!
}
```
+
## Fields
| Name | Type | Description |
| ---- |------| ----------- |
-| `outputIndex` | [`BigInt!`](../../scalars/bigint) | Index of the output in the output box. |
-| `outputHashesSiblings` | [`[String]!`](../../scalars/string) | Array of sibling hashes in the output box merkle tree. |
+| `validity`| [`OutputValidityProof!`](../../objects/output-validity-proof) | Validity proof for an output. |
+| `context`| [`String!`](../../scalars/string) | Data that allows the validity proof to be contextualized within submitted claims, given as a payload in Ethereum hex binary format, starting with '0x'. |
+
+
+
-## Example Query
-```graphql
-query {
- voucher(outputIndex: 1) {
- proof {
- outputIndex
- outputHashesSiblings
- }
- }
-}
-```
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-connection.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-connection.md
index c7c90c0c..a79b44fc 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-connection.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-connection.md
@@ -4,46 +4,26 @@ title: ReportConnection
hide_table_of_contents: false
---
-Represents a paginated list of reports.
+
+Represents a paginated connection of Reports.
```graphql
type ReportConnection {
- "Total number of entries that match the query"
- totalCount: Int!
- "List of edges in the connection"
edges: [ReportEdge!]!
- "Information about the current page"
pageInfo: PageInfo!
}
```
+
## Fields
| Name | Type | Description |
-| ---- |------| ----------- |
-| `totalCount` | [`Int!`](../../scalars/int) | Total number of entries that match the query. |
-| `edges` | [`[ReportEdge!]!`](../../objects/report-edge) | List of edges in the connection. |
-| `pageInfo` | [`PageInfo!`](../../objects/page-info) | Information about the current page. |
+| ---- |------| ------|
+| `edges`| [`ReportEdge`](../../objects/report-edge) | A list of `ReportEdge` objects. Each edge contains an `Input` object and a cursor for pagination. |
+| `pageInfo`| [`PageInfo`](../../objects/page-info) | Metadata about the pagination. |
+
+
+
+
-## Example Query
-```graphql
-query {
- reports(first: 10) {
- totalCount
- edges {
- node {
- index
- payload
- }
- cursor
- }
- pageInfo {
- hasNextPage
- hasPreviousPage
- startCursor
- endCursor
- }
- }
-}
-```
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-edge.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-edge.md
index 91959d2f..a6fba549 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-edge.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-edge.md
@@ -4,36 +4,26 @@ title: ReportEdge
hide_table_of_contents: false
---
-Represents a single report in a paginated list.
+
+Pagination entry
```graphql
type ReportEdge {
- "The report at this edge"
node: Report!
- "A cursor for use in pagination"
cursor: String!
}
```
-## Fields
+
+### Fields
+
| Name | Type | Description |
-| ---- |------| ----------- |
-| `node` | [`Report!`](../../objects/report) | The report at this edge. |
-| `cursor` | [`String!`](../../scalars/string) | A cursor for use in pagination. |
+| ---- | ---- | ----------- |
+| `node` | [`Report!`](../../objects/report) | The Report object. |
+| `cursor` | [`String!`](../../scalars/string) | A string that serves as a pagination cursor for this particular edge. |
+
+
+
-## Example Query
-```graphql
-query {
- reports(first: 10) {
- edges {
- node {
- index
- payload
- }
- cursor
- }
- }
-}
-```
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report.md
index 8d8fd8f5..ba904c27 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report.md
@@ -4,44 +4,28 @@ title: Report
hide_table_of_contents: false
---
-Application log or diagnostic information.
+
+Represents application log or diagnostic information.
```graphql
type Report {
- "Report index within the context of the input that produced it"
index: Int!
- "Input whose processing produced the report"
input: Input!
- "Report data as a payload in Ethereum hex binary format, starting with '0x'"
payload: String!
- "The application that produced the report"
- application: Application!
}
```
+
## Fields
| Name | Type | Description |
| ---- |------| ----------- |
-| `index` | [`Int!`](../../scalars/int) | Report index within the context of the input that produced it. |
-| `input` | [`Input!`](../../objects/input) | Input whose processing produced the report. |
-| `payload` | [`String!`](../../scalars/string) | Report data as a payload in Ethereum hex binary format, starting with '0x'. |
-| `application` | [`Application!`](../../objects/application) | The application that produced the report. |
+| `index`| [`Int!`](../../scalars/int) | Unique identifier for the report. |
+| `input`| [`Input!`](../../objects/input) | The input associated with this report. |
+| `payload`| [`String!`](../../scalars/string) | The actual data/content of the report. |
+
+
+
+
-## Example Query
-```graphql
-query {
- report(reportIndex: 1) {
- index
- input {
- index
- }
- payload
- application {
- address
- name
- }
- }
-}
-```
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-connection.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-connection.md
index 1f7eaec2..02c05225 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-connection.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-connection.md
@@ -4,50 +4,26 @@ title: VoucherConnection
hide_table_of_contents: false
---
-Represents a paginated list of vouchers.
+
+Represents a paginated connection of Vouchers.
```graphql
type VoucherConnection {
- "Total number of entries that match the query"
- totalCount: Int!
- "List of edges in the connection"
edges: [VoucherEdge!]!
- "Information about the current page"
pageInfo: PageInfo!
}
```
+
## Fields
| Name | Type | Description |
-| ---- |------| ----------- |
-| `totalCount` | [`Int!`](../../scalars/int) | Total number of entries that match the query. |
-| `edges` | [`[VoucherEdge!]!`](../../objects/voucher-edge) | List of edges in the connection. |
-| `pageInfo` | [`PageInfo!`](../../objects/page-info) | Information about the current page. |
+| ---- | ---- | ----------- |
+| `edges` | [`[VoucherEdge!]!`](../../objects/voucher-edge) | A list of `VoucherEdge` objects. Each edge contains a `Voucher` object and a cursor for pagination. |
+| `pageInfo` | [`PageInfo!`](../../objects/page-info) | Pagination metadata. |
+
+
+
+
-## Example Query
-```graphql
-query {
- vouchers(first: 10) {
- totalCount
- edges {
- node {
- index
- destination
- payload
- value
- executed
- transactionHash
- }
- cursor
- }
- pageInfo {
- hasNextPage
- hasPreviousPage
- startCursor
- endCursor
- }
- }
-}
-```
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-edge.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-edge.md
index 0e5a8e8a..99d42d30 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-edge.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-edge.md
@@ -4,40 +4,26 @@ title: VoucherEdge
hide_table_of_contents: false
---
-Represents a single voucher in a paginated list.
+
+Pagination entry.
```graphql
type VoucherEdge {
- "The voucher at this edge"
node: Voucher!
- "A cursor for use in pagination"
cursor: String!
}
```
+
## Fields
| Name | Type | Description |
-| ---- |------| ----------- |
-| `node` | [`Voucher!`](../../objects/voucher) | The voucher at this edge. |
-| `cursor` | [`String!`](../../scalars/string) | A cursor for use in pagination. |
+| ---- | ---- | ----------- |
+| `node` | [`Voucher!`](../../objects/voucher) | The `Voucher` object. |
+| `cursor` | [`String!`](../../scalars/string) | A string that serves as a pagination cursor for this particular edge. |
+
+
+
+
-## Example Query
-```graphql
-query {
- vouchers(first: 10) {
- edges {
- node {
- index
- destination
- payload
- value
- executed
- transactionHash
- }
- cursor
- }
- }
-}
-```
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher.md
index b2959d38..6713e671 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher.md
@@ -4,67 +4,30 @@ title: Voucher
hide_table_of_contents: false
---
+
Representation of a transaction that can be carried out on the base layer blockchain, such as a transfer of assets.
```graphql
type Voucher {
- "Voucher index within the context of the input that produced it"
index: Int!
- "Input whose processing produced the voucher"
input: Input!
- "Transaction destination address in Ethereum hex binary format (20 bytes), starting with '0x'"
destination: String!
- "Transaction payload in Ethereum hex binary format, starting with '0x'"
payload: String!
- "Proof object that allows this voucher to be validated and executed on the base layer blockchain"
proof: Proof
- "Value to be sent with the transaction"
- value: BigInt
- "Indicates whether the voucher has been executed on the base layer blockchain"
- executed: Boolean
- "The hash of executed transaction"
- transactionHash: String
- "The application that produced the voucher"
- application: Application!
}
```
+
## Fields
| Name | Type | Description |
| ---- |------| ----------- |
-| `index` | [`Int!`](../../scalars/int) | Voucher index within the context of the input that produced it. |
-| `input` | [`Input!`](../../objects/input) | Input whose processing produced the voucher. |
-| `destination` | [`String!`](../../scalars/string) | Transaction destination address in Ethereum hex binary format (20 bytes), starting with '0x'. |
-| `payload` | [`String!`](../../scalars/string) | Transaction payload in Ethereum hex binary format, starting with '0x'. |
-| `proof` | [`Proof`](../../objects/proof) | Proof object that allows this voucher to be validated and executed on the base layer blockchain. |
-| `value` | [`BigInt`](../../scalars/bigint) | Value to be sent with the transaction. |
-| `executed` | [`Boolean`](../../scalars/boolean) | Indicates whether the voucher has been executed on the base layer blockchain. |
-| `transactionHash` | [`String`](../../scalars/string) | The hash of executed transaction. |
-| `application` | [`Application!`](../../objects/application) | The application that produced the voucher. |
+| `index`| [`Int!`](../../scalars/int) | Unique identifier for the voucher. |
+| `input`| [`Input!`](../../objects/input) | The input associated with this voucher. |
+| `destination`| [`String!`](../../scalars/string) | The address or identifier of the voucher's destination. |
+| `payload`| [`String!`](../../scalars/string) | The actual data/content of the voucher. |
+| `proof`| [`Proof`](../../objects/proof) | Proof object that allows this voucher to be validated and executed on the base layer blockchain(if available). |
+
+
-## Example Query
-```graphql
-query {
- voucher(address: "0x123...") {
- index
- input {
- index
- }
- destination
- payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- value
- executed
- transactionHash
- application {
- address
- name
- }
- }
-}
-```
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/notices.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/notices.md
index abc5c2c8..92c5749a 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/notices.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/notices.md
@@ -11,32 +11,28 @@ Notices are informational statements that can be validated in the base layer blo
Retrieve a specific notice based on its index and associated input index.
```graphql
-query notice($outputIndex: Int!) {
- notice(outputIndex: $outputIndex) {
+query notice($noticeIndex: Int!, $inputIndex: Int!) {
+ notice(noticeIndex: $noticeIndex, inputIndex: $inputIndex) {
index
input {
- id
index
- status
+ timestamp
msgSender
- blockTimestamp
blockNumber
- payload
- inputBoxIndex
- prevRandao
- application {
- address
- name
- }
}
payload
proof {
- outputIndex
- outputHashesSiblings
- }
- application {
- address
- name
+ validity {
+ inputIndexWithinEpoch
+ outputIndexWithinInput
+ outputHashesRootHash
+ vouchersEpochRootHash
+ noticesEpochRootHash
+ machineStateHash
+ outputHashInOutputHashesSiblings
+ outputHashesInEpochSiblings
+ }
+ context
}
}
}
@@ -46,9 +42,10 @@ For notices, the API provides access to proof data that can be used for validati
### Arguments
-| Name | Type | Description |
-| ------------ | --------------------------- | ---------------------------------------------- |
-| `outputIndex` | [`Int!`](../../scalars/int) | Index of the notice to retrieve. |
+| Name | Type | Description |
+| ------------- | --------------------------- | ---------------------------------------------- |
+| `noticeIndex` | [`Int!`](../../scalars/int) | Index of the notice to retrieve. |
+| `inputIndex` | [`Int!`](../../scalars/int) | Index of the input associated with the notice. |
### Response Type
@@ -65,35 +62,13 @@ query notices {
node {
index
input {
- id
index
- status
+ timestamp
msgSender
- blockTimestamp
blockNumber
- payload
- inputBoxIndex
- prevRandao
- application {
- address
- name
- }
}
payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- application {
- address
- name
- }
}
- cursor
- }
- pageInfo {
- hasNextPage
- endCursor
}
}
}
@@ -118,21 +93,14 @@ query noticesByInput($inputIndex: Int!) {
edges {
node {
index
- payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- application {
- address
- name
+ input {
+ index
+ timestamp
+ msgSender
+ blockNumber
}
+ payload
}
- cursor
- }
- pageInfo {
- hasNextPage
- endCursor
}
}
}
@@ -156,31 +124,15 @@ query noticesByInput($inputIndex: Int!) {
```graphql
query {
- notice(outputIndex: 1) {
+ notice(noticeIndex: 3, inputIndex: 2) {
index
- input {
- id
- index
- status
- msgSender
- blockTimestamp
- blockNumber
- payload
- inputBoxIndex
- prevRandao
- application {
- address
- name
- }
- }
payload
proof {
- outputIndex
- outputHashesSiblings
- }
- application {
- address
- name
+ validity {
+ inputIndexWithinEpoch
+ outputIndexWithinInput
+ }
+ context
}
}
}
@@ -195,29 +147,10 @@ query {
node {
index
input {
- id
index
- status
- msgSender
- blockTimestamp
- blockNumber
- payload
- inputBoxIndex
- prevRandao
- application {
- address
- name
- }
+ timestamp
}
payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- application {
- address
- name
- }
}
cursor
}
@@ -239,14 +172,6 @@ query {
node {
index
payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- application {
- address
- name
- }
}
cursor
}
@@ -258,80 +183,3 @@ query {
}
}
```
-
-4. Listing notices with proof data and application information:
-
-```graphql
-query {
- notices(first: 10) {
- edges {
- node {
- index
- input {
- id
- index
- status
- msgSender
- blockTimestamp
- blockNumber
- payload
- inputBoxIndex
- prevRandao
- application {
- address
- name
- }
- }
- payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- application {
- address
- name
- }
- }
- cursor
- }
- pageInfo {
- hasNextPage
- endCursor
- }
- }
-}
-```
-
-5. Fetching a specific notice by output index:
-
-```graphql
-query {
- notice(outputIndex: 1) {
- index
- input {
- id
- index
- status
- msgSender
- blockTimestamp
- blockNumber
- payload
- inputBoxIndex
- prevRandao
- application {
- address
- name
- }
- }
- payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- application {
- address
- name
- }
- }
-}
-```
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/vouchers.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/vouchers.md
index c5bbf344..9e4e2560 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/vouchers.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/vouchers.md
@@ -12,36 +12,29 @@ Vouchers represent transactions that can be carried out on the base layer blockc
Retrieve a specific voucher based on its index and associated input index.
```graphql
-query voucher($outputIndex: Int!) {
- voucher(outputIndex: $outputIndex) {
+query voucher($voucherIndex: Int!, $inputIndex: Int!) {
+ voucher(voucherIndex: $voucherIndex, inputIndex: $inputIndex) {
index
input {
- id
index
- status
+ timestamp
msgSender
- blockTimestamp
blockNumber
- payload
- inputBoxIndex
- prevRandao
- application {
- address
- name
- }
}
destination
payload
proof {
- outputIndex
- outputHashesSiblings
- }
- value
- executed
- transactionHash
- application {
- address
- name
+ validity {
+ inputIndexWithinEpoch
+ outputIndexWithinInput
+ outputHashesRootHash
+ vouchersEpochRootHash
+ noticesEpochRootHash
+ machineStateHash
+ outputHashInOutputHashesSiblings
+ outputHashesInEpochSiblings
+ }
+ context
}
}
}
@@ -52,7 +45,8 @@ For vouchers, the API provides access to proof data that can be used for validat
| Name | Type | Description |
| ---- | ---- | ----------- |
-| `outputIndex` | [`Int!`](../../scalars/int) | The index of the voucher to retrieve. |
+| `voucherIndex` | [`Int!`](../../scalars/int) | The index of the voucher to retrieve. |
+| `inputIndex` | [`Int!`](../../scalars/int) | The index of the associated input. |
@@ -72,33 +66,13 @@ query vouchers($first: Int, $after: String) {
node {
index
input {
- id
index
- status
+ timestamp
msgSender
- blockTimestamp
blockNumber
- payload
- inputBoxIndex
- prevRandao
- application {
- address
- name
- }
}
destination
payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- value
- executed
- transactionHash
- application {
- address
- name
- }
}
cursor
}
@@ -136,17 +110,6 @@ query vouchersByInput($inputIndex: Int!, $first: Int, $after: String) {
index
destination
payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- value
- executed
- transactionHash
- application {
- address
- name
- }
}
cursor
}
@@ -178,39 +141,20 @@ query vouchersByInput($inputIndex: Int!, $first: Int, $after: String) {
1. Fetching a specific voucher:
```graphql
- query {
- voucher(outputIndex: 1) {
- index
- input {
- id
+ query {
+ voucher(voucherIndex: 3, inputIndex: 2) {
index
- status
- msgSender
- blockTimestamp
- blockNumber
+ destination
payload
- inputBoxIndex
- prevRandao
- application {
- address
- name
+ proof {
+ validity {
+ inputIndexWithinEpoch
+ outputIndexWithinInput
+ }
+ context
}
}
- destination
- payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- value
- executed
- transactionHash
- application {
- address
- name
- }
}
- }
```
2. Listing earlier(first 5) vouchers:
@@ -222,33 +166,11 @@ query vouchersByInput($inputIndex: Int!, $first: Int, $after: String) {
node {
index
input {
- id
index
- status
- msgSender
- blockTimestamp
- blockNumber
- payload
- inputBoxIndex
- prevRandao
- application {
- address
- name
- }
+ timestamp
}
destination
payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- value
- executed
- transactionHash
- application {
- address
- name
- }
}
cursor
}
@@ -271,17 +193,6 @@ query vouchersByInput($inputIndex: Int!, $first: Int, $after: String) {
index
destination
payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- value
- executed
- transactionHash
- application {
- address
- name
- }
}
cursor
}
@@ -292,88 +203,4 @@ query vouchersByInput($inputIndex: Int!, $first: Int, $after: String) {
}
}
}
- ```
-
-4. Listing all vouchers with proof data:
-
- ```graphql
- query {
- vouchers(first: 10) {
- edges {
- node {
- index
- input {
- id
- index
- status
- msgSender
- blockTimestamp
- blockNumber
- payload
- inputBoxIndex
- prevRandao
- application {
- address
- name
- }
- }
- destination
- payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- value
- executed
- transactionHash
- application {
- address
- name
- }
- }
- }
- pageInfo {
- hasNextPage
- endCursor
- }
- }
- }
- ```
-
-5. Fetching a specific voucher by output index:
-
- ```graphql
- query {
- voucher(outputIndex: 1) {
- index
- input {
- id
- index
- status
- msgSender
- blockTimestamp
- blockNumber
- payload
- inputBoxIndex
- prevRandao
- application {
- address
- name
- }
- }
- destination
- payload
- proof {
- outputIndex
- outputHashesSiblings
- }
- value
- executed
- transactionHash
- application {
- address
- name
- }
- }
- }
```
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/index.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/index.md
index 21839187..66c72559 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/index.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/index.md
@@ -12,7 +12,7 @@ resources:
In a Cartesi dApp, the frontend and backend components communicate through the Rollups framework using HTTP and GraphQL APIs.
-When designing the APIs for this communication framework, we aimed to ensure that developers could create their applications without excessive concern about the low-level components of Cartesi Rollups.
+When designing the APIs for this communication with the framework, we wanted to ensure developers could create their applications without worrying too much about the low-level components of Cartesi Rollups.
## Backend APIs
@@ -20,29 +20,30 @@ In a typical Cartesi dApp, the backend contains the application's state and veri
The dApp's backend interacts with the Cartesi Rollups framework by retrieving processing requests and submitting corresponding outputs.
-This interaction occurs through a set of HTTP endpoints, as illustrated in the figure below:
+This is accomplished by calling a set of HTTP endpoints, as illustrated by the figure below:

-You can send two types of requests to an application depending on whether you want to change or read the state:
+You can send two requests to an application depending on whether you want to change or read the state.
-- **Advance**: With this request, input data changes the state of the dApp.
+- **Advance**: In this request, any input data changes the state of the dApp.
+
+- **Inspect**: This involves making an external HTTP API call to the Cartesi Node to read the dApp state without changing it.
-- **Inspect**: This involves making an external HTTP API call to the Cartesi Node to read the dApp state without modifying it.
## Base Layer Contracts
The frontend component of the dApp needs to access the Cartesi Rollups framework to submit user requests and retrieve the corresponding outputs produced by the backend.
-The figure below illustrates the main use cases for these interactions:
+The figure below details some of the main use cases for these interactions:

-- [`addInput()`](./contracts/input-box/#addinput) — This function submits input data to the InputBox smart contract on the base layer as a regular JSON-RPC blockchain transaction. When the transaction is mined and executed, it emits an event containing the submitted input's index, which the frontend can later use to query associated outputs.
+- [`addInput()`](./contracts/input-box/#addinput) — This function submits input data to the InputBox smart contract on the base layer as a regular JSON-RPC blockchain transaction. When that transaction is mined and executed, an event containing the submitted input’s index is emitted, which the frontend can later use to query associated outputs.
-- [`executeOutput()`](./contracts/application/#executeoutput) — Submits a JSON-RPC blockchain transaction to request the execution of a given voucher or notice by the [`Application`](./contracts/application.md) smart contract on the base layer. Vouchers can only be executed when an epoch is closed.
+- [`executeOutput()`](./contracts/application/#executeoutput) — Submits a JSON-RPC blockchain transaction to request that a given voucher or notice be executed by the [`Application`](./contracts/application.md) smart contract on the base layer. Vouchers can only be executed when an epoch is closed.
-- Query outputs — You can submit a query to a Cartesi node to retrieve vouchers, notices, and reports as specified by the Cartesi Rollups GraphQL schema.
+- Query outputs — You can submit a query to a Cartesi node to retrieve vouchers, notices, and reports, as specified by the Cartesi Rollups GraphQL schema.
- Inspect state — You can make an HTTP call to the Cartesi node to retrieve arbitrary dApp-specific application state.
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/applications/get.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/applications/get.md
index 02eff86f..daff9086 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/applications/get.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/applications/get.md
@@ -33,7 +33,7 @@ The `cartesi_getApplication` method retrieves detailed information about a speci
"jsonrpc": "2.0",
"result": {
"data": {
- "name": "calculator",
+ "name": "calculator",
"iapplication_address": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F",
"iconsensus_address": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F",
"iinputbox_address": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F",
@@ -46,9 +46,9 @@ The `cartesi_getApplication` method retrieves detailed information about a speci
"last_input_check_block": "0x1",
"last_output_check_block": "0x1",
"processed_inputs": "0x1",
- "created_at": "2024-01-01T00:00:00Z",
- "updated_at": "2024-01-01T00:00:00Z",
- "execution_parameters": {
+ "created_at": "2024-01-01T00:00:00Z",
+ "updated_at": "2024-01-01T00:00:00Z",
+ "execution_parameters": {
"snapshot_policy": "NONE",
"advance_inc_cycles": "0x1000",
"advance_max_cycles": "0x10000",
@@ -118,4 +118,4 @@ The `cartesi_getApplication` method retrieves detailed information about a speci
|---------|------------------------|--------------------------------------------------|
| -32602 | Invalid params | Invalid parameter values |
| -32000 | Application not found | The specified application does not exist |
-| -32603 | Internal error | An internal error occurred |
\ No newline at end of file
+| -32603 | Internal error | An internal error occurred |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/applications/list.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/applications/list.md
index 35fd2964..55abab6e 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/applications/list.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/applications/list.md
@@ -136,4 +136,4 @@ The `cartesi_listApplications` method returns a paginated list of applications r
| Code | Message | Description |
|---------|------------------------|--------------------------------------------------|
| -32602 | Invalid params | Invalid parameter values |
-| -32603 | Internal error | An internal error occurred |
\ No newline at end of file
+| -32603 | Internal error | An internal error occurred |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/epochs/get.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/epochs/get.md
index 27801cc4..9fe4d132 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/epochs/get.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/epochs/get.md
@@ -42,9 +42,9 @@ The `cartesi_getEpoch` method retrieves detailed information about a specific ep
"claim_transaction_hash": null,
"status": "OPEN",
"virtual_index": "0x1",
- "created_at": "2024-01-01T00:00:00Z",
+ "created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
- }
+ }
},
"id": 1
}
@@ -71,4 +71,4 @@ The `cartesi_getEpoch` method retrieves detailed information about a specific ep
| -32602 | Invalid params | Invalid parameter values |
| -32000 | Application not found | The specified application does not exist |
| -32001 | Epoch not found | The specified epoch does not exist |
-| -32603 | Internal error | An internal error occurred |
\ No newline at end of file
+| -32603 | Internal error | An internal error occurred |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/epochs/last-accepted.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/epochs/last-accepted.md
index 6a462a13..1b56d9e0 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/epochs/last-accepted.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/epochs/last-accepted.md
@@ -50,4 +50,4 @@ The `cartesi_getLastAcceptedEpochIndex` method retrieves the latest accepted epo
|---------|------------------------|--------------------------------------------------|
| -32602 | Invalid params | Invalid parameter values |
| -32000 | Application not found | The specified application does not exist |
-| -32603 | Internal error | An internal error occurred |
\ No newline at end of file
+| -32603 | Internal error | An internal error occurred |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/inputs/get.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/inputs/get.md
index 564321c9..abfd335c 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/inputs/get.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/inputs/get.md
@@ -49,13 +49,13 @@ The `cartesi_getInput` method retrieves detailed information about a specific in
"index": "0x1",
"payload": "0x48656c6c6f"
},
- "status": "ACCEPTED",
+ "status": "ACCEPTED",
"machine_hash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"outputs_hash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"transaction_reference": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
- }
+ }
},
"id": 1
}
@@ -97,4 +97,4 @@ The `cartesi_getInput` method retrieves detailed information about a specific in
| -32602 | Invalid params | Invalid parameter values |
| -32000 | Application not found | The specified application does not exist |
| -32002 | Input not found | The specified input does not exist |
-| -32603 | Internal error | An internal error occurred |
\ No newline at end of file
+| -32603 | Internal error | An internal error occurred |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/inputs/list.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/inputs/list.md
index a23a2435..b19f93d1 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/inputs/list.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/inputs/list.md
@@ -104,4 +104,4 @@ The `cartesi_listInputs` method returns a paginated list of inputs for a specifi
|---------|------------------------|--------------------------------------------------|
| -32602 | Invalid params | Invalid parameter values |
| -32603 | Internal error | An internal error occurred |
-| -32000 | Application not found | The specified application does not exist |
\ No newline at end of file
+| -32000 | Application not found | The specified application does not exist |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/inputs/processed-count.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/inputs/processed-count.md
index c0519eaf..22cc6d0c 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/inputs/processed-count.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/inputs/processed-count.md
@@ -50,4 +50,4 @@ The `cartesi_getProcessedInputCount` method returns the total number of inputs t
|---------|------------------------|--------------------------------------------------|
| -32602 | Invalid params | Invalid parameter values |
| -32000 | Application not found | The specified application does not exist |
-| -32603 | Internal error | An internal error occurred |
\ No newline at end of file
+| -32603 | Internal error | An internal error occurred |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/outputs/list.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/outputs/list.md
index 645ce816..e791300a 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/outputs/list.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/outputs/list.md
@@ -100,4 +100,4 @@ The `cartesi_listOutputs` method returns a paginated list of outputs for a speci
|---------|------------------------|--------------------------------------------------|
| -32602 | Invalid params | Invalid parameter values |
| -32603 | Internal error | An internal error occurred |
-| -32000 | Application not found | The specified application does not exist |
\ No newline at end of file
+| -32000 | Application not found | The specified application does not exist |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/reports/get.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/reports/get.md
index 7422c649..427790c2 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/reports/get.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/reports/get.md
@@ -65,4 +65,4 @@ The `cartesi_getReport` method retrieves detailed information about a specific r
| -32602 | Invalid params | Invalid parameter values |
| -32000 | Application not found | The specified application does not exist |
| -32004 | Report not found | The specified report does not exist |
-| -32603 | Internal error | An internal error occurred |
\ No newline at end of file
+| -32603 | Internal error | An internal error occurred |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/reports/list.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/reports/list.md
index 4c101f50..2f76c7c7 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/reports/list.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/methods/reports/list.md
@@ -85,4 +85,4 @@ The `cartesi_listReports` method returns a paginated list of reports for a speci
|---------|------------------------|--------------------------------------------------|
| -32602 | Invalid params | Invalid parameter values |
| -32603 | Internal error | An internal error occurred |
-| -32000 | Application not found | The specified application does not exist |
\ No newline at end of file
+| -32000 | Application not found | The specified application does not exist |
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/types.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/types.md
index 02000203..a5d13cb0 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/types.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/jsonrpc/types.md
@@ -9,14 +9,78 @@ This page documents the data types used in the Cartesi Rollups Node API. These t
## Basic Types
-### HexString
-A string representing a hexadecimal value, prefixed with "0x". Used for addresses, hashes, and other binary data.
+### EthereumAddress
+A string representing an Ethereum address in hexadecimal format, prefixed with "0x".
+
+Pattern: `^0x[a-fA-F0-9]{40}$`
Example:
```json
"0x71C7656EC7ab88b098defB751B7401B5f6d8976F"
```
+### Hash
+A string representing a hash value in hexadecimal format, prefixed with "0x".
+
+Pattern: `^0x[a-fA-F0-9]{64}$`
+
+Example:
+```json
+"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
+```
+
+### ByteArray
+A string representing binary data in hexadecimal format, prefixed with "0x".
+
+Pattern: `^0x[a-fA-F0-9]*$`
+
+Example:
+```json
+"0x1234567890abcdef"
+```
+
+### UnsignedInteger
+A string representing an unsigned integer in hexadecimal format, prefixed with "0x".
+
+Pattern: `^0x[a-fA-F0-9]{1,16}$`
+
+Example:
+```json
+"0x1"
+```
+
+### FunctionSelector
+A string representing a function selector in hexadecimal format, prefixed with "0x".
+
+Pattern: `^0x[a-fA-F0-9]{8}$`
+
+Example:
+```json
+"0xa9059cbb"
+```
+
+### ApplicationName
+A string representing an application name.
+
+Pattern: `^[a-z0-9_-]+$`
+
+Example:
+```json
+"my-application"
+```
+
+### NameOrAddress
+Either an ApplicationName or an EthereumAddress.
+
+Example:
+```json
+"my-application"
+```
+or
+```json
+"0x71C7656EC7ab88b098defB751B7401B5f6d8976F"
+```
+
### Timestamp
A string representing a timestamp in ISO 8601 format.
@@ -33,7 +97,7 @@ The current state of an application.
Values:
- `ENABLED`: The application is enabled and processing inputs
- `DISABLED`: The application is disabled and not processing inputs
-- `ERROR`: The application encountered an error and is not processing inputs
+- `INOPERABLE`: The application is inoperable
Example:
```json
@@ -46,20 +110,30 @@ The current status of an epoch.
Values:
- `OPEN`: The epoch is open and accepting inputs
- `CLOSED`: The epoch is closed and not accepting inputs
-- `PROCESSED`: The epoch has been processed
+- `INPUTS_PROCESSED`: The epoch inputs have been processed
+- `CLAIM_COMPUTED`: The epoch claim has been computed
+- `CLAIM_SUBMITTED`: The epoch claim has been submitted
+- `CLAIM_ACCEPTED`: The epoch claim has been accepted
+- `CLAIM_REJECTED`: The epoch claim has been rejected
Example:
```json
"OPEN"
```
-### InputStatus
+### InputCompletionStatus
The current status of an input.
Values:
+- `NONE`: No status assigned
- `ACCEPTED`: The input has been accepted and processed
- `REJECTED`: The input has been rejected
-- `PENDING`: The input is pending processing
+- `EXCEPTION`: The input processing resulted in an exception
+- `MACHINE_HALTED`: The machine halted during input processing
+- `OUTPUTS_LIMIT_EXCEEDED`: The outputs limit was exceeded
+- `CYCLE_LIMIT_EXCEEDED`: The cycle limit was exceeded
+- `TIME_LIMIT_EXCEEDED`: The time limit was exceeded
+- `PAYLOAD_LENGTH_LIMIT_EXCEEDED`: The payload length limit was exceeded
Example:
```json
@@ -71,8 +145,8 @@ The snapshot policy for an application.
Values:
- `NONE`: No snapshots are taken
-- `EVERY_EPOCH`: A snapshot is taken at the end of each epoch
- `EVERY_INPUT`: A snapshot is taken after each input
+- `EVERY_EPOCH`: A snapshot is taken at the end of each epoch
Example:
```json
@@ -86,19 +160,19 @@ Represents a Cartesi Rollups application.
```typescript
interface Application {
- name: string;
- iapplication_address: HexString;
- iconsensus_address: HexString;
- iinputbox_address: HexString;
- template_hash: HexString;
- epoch_length: HexString;
- data_availability: HexString;
+ name: ApplicationName;
+ iapplication_address: EthereumAddress;
+ iconsensus_address: EthereumAddress;
+ iinputbox_address: EthereumAddress;
+ template_hash: Hash;
+ epoch_length: UnsignedInteger;
+ data_availability: ByteArray;
state: ApplicationState;
reason: string;
- iinputbox_block: HexString;
- last_input_check_block: HexString;
- last_output_check_block: HexString;
- processed_inputs: HexString;
+ iinputbox_block: UnsignedInteger;
+ last_input_check_block: UnsignedInteger;
+ last_output_check_block: UnsignedInteger;
+ processed_inputs: UnsignedInteger;
created_at: Timestamp;
updated_at: Timestamp;
execution_parameters: ExecutionParameters;
@@ -111,17 +185,17 @@ Configuration parameters for application execution.
```typescript
interface ExecutionParameters {
snapshot_policy: SnapshotPolicy;
- advance_inc_cycles: HexString;
- advance_max_cycles: HexString;
- inspect_inc_cycles: HexString;
- inspect_max_cycles: HexString;
- advance_inc_deadline: HexString;
- advance_max_deadline: HexString;
- inspect_inc_deadline: HexString;
- inspect_max_deadline: HexString;
- load_deadline: HexString;
- store_deadline: HexString;
- fast_deadline: HexString;
+ advance_inc_cycles: UnsignedInteger;
+ advance_max_cycles: UnsignedInteger;
+ inspect_inc_cycles: UnsignedInteger;
+ inspect_max_cycles: UnsignedInteger;
+ advance_inc_deadline: UnsignedInteger; // Duration in nanoseconds
+ advance_max_deadline: UnsignedInteger; // Duration in nanoseconds
+ inspect_inc_deadline: UnsignedInteger; // Duration in nanoseconds
+ inspect_max_deadline: UnsignedInteger; // Duration in nanoseconds
+ load_deadline: UnsignedInteger; // Duration in nanoseconds
+ store_deadline: UnsignedInteger; // Duration in nanoseconds
+ fast_deadline: UnsignedInteger; // Duration in nanoseconds
max_concurrent_inspects: number;
created_at: Timestamp;
updated_at: Timestamp;
@@ -133,13 +207,13 @@ Represents a Cartesi Rollups epoch.
```typescript
interface Epoch {
- index: HexString;
- first_block: HexString;
- last_block: HexString;
- claim_hash: HexString | null;
- claim_transaction_hash: HexString | null;
+ index: UnsignedInteger;
+ first_block: UnsignedInteger;
+ last_block: UnsignedInteger;
+ claim_hash: Hash | null;
+ claim_transaction_hash: Hash | null;
status: EpochStatus;
- virtual_index: HexString;
+ virtual_index: UnsignedInteger;
created_at: Timestamp;
updated_at: Timestamp;
}
@@ -150,33 +224,33 @@ Represents a Cartesi Rollups input.
```typescript
interface Input {
- epoch_index: HexString;
- index: HexString;
- block_number: HexString;
- raw_data: HexString;
- decoded_data: DecodedInput;
- status: InputStatus;
- machine_hash: HexString;
- outputs_hash: HexString;
- transaction_reference: HexString;
+ epoch_index: UnsignedInteger;
+ index: UnsignedInteger;
+ block_number: UnsignedInteger;
+ raw_data: ByteArray;
+ decoded_data: EvmAdvance | null;
+ status: InputCompletionStatus;
+ machine_hash: Hash | null;
+ outputs_hash: Hash | null;
+ transaction_reference: ByteArray;
created_at: Timestamp;
updated_at: Timestamp;
}
```
-### DecodedInput
-The decoded data of an input.
+### EvmAdvance
+The decoded data of an EVM advance input.
```typescript
-interface DecodedInput {
- chain_id: HexString;
- application_contract: HexString;
- sender: HexString;
- block_number: HexString;
- block_timestamp: HexString;
- prev_randao: HexString;
- index: HexString;
- payload: HexString;
+interface EvmAdvance {
+ chain_id: UnsignedInteger;
+ application_contract: EthereumAddress;
+ sender: EthereumAddress;
+ block_number: UnsignedInteger;
+ block_timestamp: UnsignedInteger;
+ prev_randao: ByteArray;
+ index: UnsignedInteger;
+ payload: ByteArray;
}
```
@@ -185,27 +259,57 @@ Represents a Cartesi Rollups output (notice, voucher, or DELEGATECALL voucher).
```typescript
interface Output {
- epoch_index: HexString;
- input_index: HexString;
- index: HexString;
- raw_data: HexString;
- decoded_data: DecodedOutput;
- hash: HexString;
- output_hashes_siblings: HexString[];
- execution_transaction_hash: HexString;
+ epoch_index: UnsignedInteger;
+ input_index: UnsignedInteger;
+ index: UnsignedInteger;
+ raw_data: ByteArray;
+ decoded_data: DecodedOutput | null;
+ hash: Hash | null;
+ output_hashes_siblings: Hash[] | null;
+ execution_transaction_hash: Hash | null;
created_at: Timestamp;
updated_at: Timestamp;
}
```
+### Notice
+Represents a notice output.
+
+```typescript
+interface Notice {
+ type: FunctionSelector;
+ payload: ByteArray;
+}
+```
+
+### Voucher
+Represents a voucher output.
+
+```typescript
+interface Voucher {
+ type: FunctionSelector;
+ destination: EthereumAddress;
+ value: string;
+ payload: ByteArray;
+}
+```
+
+### DelegateCallVoucher
+Represents a DELEGATECALL voucher output.
+
+```typescript
+interface DelegateCallVoucher {
+ type: FunctionSelector;
+ destination: EthereumAddress;
+ payload: ByteArray;
+}
+```
+
### DecodedOutput
The decoded data of an output.
```typescript
-interface DecodedOutput {
- type: HexString;
- payload: HexString;
-}
+type DecodedOutput = Notice | Voucher | DelegateCallVoucher;
```
### Report
@@ -213,10 +317,10 @@ Represents a Cartesi Rollups report.
```typescript
interface Report {
- epoch_index: HexString;
- input_index: HexString;
- index: HexString;
- raw_data: HexString;
+ epoch_index: UnsignedInteger;
+ input_index: UnsignedInteger;
+ index: UnsignedInteger;
+ raw_data: ByteArray;
created_at: Timestamp;
updated_at: Timestamp;
}
@@ -233,12 +337,134 @@ interface Pagination {
}
```
-### PaginatedResponse
-A generic interface for paginated responses.
+## Result Types
+
+### ApplicationListResult
+Result for listing applications.
+
+```typescript
+interface ApplicationListResult {
+ data: Application[];
+ pagination: Pagination;
+}
+```
+
+### ApplicationGetResult
+Result for getting a single application.
+
+```typescript
+interface ApplicationGetResult {
+ data: Application;
+}
+```
+
+### EpochListResult
+Result for listing epochs.
+
+```typescript
+interface EpochListResult {
+ data: Epoch[];
+ pagination: Pagination;
+}
+```
+
+### EpochGetResult
+Result for getting a single epoch.
+
+```typescript
+interface EpochGetResult {
+ data: Epoch;
+}
+```
+
+### InputListResult
+Result for listing inputs.
```typescript
-interface PaginatedResponse {
- data: T[];
+interface InputListResult {
+ data: Input[];
pagination: Pagination;
}
-```
\ No newline at end of file
+```
+
+### InputGetResult
+Result for getting a single input.
+
+```typescript
+interface InputGetResult {
+ data: Input;
+}
+```
+
+### LastAcceptedEpochIndexResult
+Result for getting the last accepted epoch index.
+
+```typescript
+interface LastAcceptedEpochIndexResult {
+ data: UnsignedInteger;
+}
+```
+
+### ProcessedInputCountResult
+Result for getting the processed input count.
+
+```typescript
+interface ProcessedInputCountResult {
+ data: UnsignedInteger;
+}
+```
+
+### OutputListResult
+Result for listing outputs.
+
+```typescript
+interface OutputListResult {
+ data: Output[];
+ pagination: Pagination;
+}
+```
+
+### OutputGetResult
+Result for getting a single output.
+
+```typescript
+interface OutputGetResult {
+ data: Output;
+}
+```
+
+### ReportListResult
+Result for listing reports.
+
+```typescript
+interface ReportListResult {
+ data: Report[];
+ pagination: Pagination;
+}
+```
+
+### ReportGetResult
+Result for getting a single report.
+
+```typescript
+interface ReportGetResult {
+ data: Report;
+}
+```
+
+### ChainIdResult
+Result for getting the chain ID.
+
+```typescript
+interface ChainIdResult {
+ data: UnsignedInteger;
+}
+```
+
+### NodeVersionResult
+Result for getting the node version.
+
+```typescript
+interface NodeVersionResult {
+ data: string; // Semantic version format
+}
\ No newline at end of file
diff --git a/cartesi-rollups_versioned_docs/version-2.0/deployment/introduction.md b/cartesi-rollups_versioned_docs/version-2.0/deployment/introduction.md
index b19a76ce..ac75b55d 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/deployment/introduction.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/deployment/introduction.md
@@ -9,11 +9,15 @@ resources:
Applications built on Cartesi Rollups are intended to be deployed to public blockchains so users can access them. This can be done by taking advantage of a cloud-based infrastructure.
-Deploying a Cartesi dApp involves two steps: deploying a smart contract that defines your dApp on-chain and then instantiating a node that runs the application’s intended backend logic.
+Deploying a Cartesi dApp involves two steps: deploying a smart contract that defines your dApp on-chain and then instantiating a node that runs the application's intended backend logic.
To facilitate the instantiation of such nodes, Cartesi provides an infrastructure for quickly getting them running in the cloud so the node can be run 24/7. This server will expose a single port to the internet so client applications can communicate with the node.
-The Cartesi rollups node is distributed as a Docker image. Any popular cloud provider, like AWS, GCP, Azure, Digital Ocean, or Linode, can run docker containers and hence can be used to host the rollups node.
+## Public snapshots
+
+For production deployments, applications must use **public snapshots** that are built through public workflows and published as public releases. This ensures transparency, reproducibility, trust, and auditability - essential for the trustless nature of blockchain applications.
+
+[Learn more about public snapshots](./snapshot.md)
## Deployment process
@@ -27,19 +31,18 @@ The smart contract that represents the application on the base layer can be depl
There are two methods to deploy an application:
-1. [Self-hosted deployment](../deployment/self-hosted.md): Deploy the application node using your infrastructure.
-
-2. Third-party service provider: Outsource running the application node to a service provider.
+1. [Self-hosted deployment](./self-hosted.md): Deploy the application node using your infrastructure
+2. Third-party service provider: Outsource running the application node to a service provider
:::caution important
-Deployment with a third-party service provider is under development and will be available in a future release.
+Deployment with a third-party service provider is under development and will be available soon.
:::
## Supported networks
As stated above, the first step in deploying a new Cartesi dApp to a blockchain requires creating a smart contract on that network that uses the Cartesi Rollups smart contracts. Cartesi has already deployed the Rollups smart contracts to several networks for convenience.
-The table below shows the list of all [networks that are currently supported](https://github.com/cartesi/rollups-contracts/tree/v1.4.0/onchain/rollups/deployments) in the latest release:
+The table below shows the list of all [networks that are currently supported](https://usecannon.com/packages/cartesi-rollups) in the latest release:
| Network Name | Chain ID |
| ---------------- | -------- |
diff --git a/cartesi-rollups_versioned_docs/version-2.0/deployment/self-hosted.md b/cartesi-rollups_versioned_docs/version-2.0/deployment/self-hosted.md
index e6573e49..e4f85dc3 100644
--- a/cartesi-rollups_versioned_docs/version-2.0/deployment/self-hosted.md
+++ b/cartesi-rollups_versioned_docs/version-2.0/deployment/self-hosted.md
@@ -1,27 +1,14 @@
---
id: self-hosted
title: Self-hosted deployment
-resources:
- - url: https://www.codecademy.com/article/installing-and-using-postgresql-locally
- title: Installing and Using PostgreSQL Locally
- - url: https://docs.digitalocean.com/products/databases/postgresql/how-to/create/
- title: How to Create PostgreSQL Database Clusters
- - url: https://www.amazonaws.cn/en/getting-started/tutorials/deploy-docker-containers/
- title: How to Deploy Docker Container - AWS
- - url: https://www.digitalocean.com/solutions/docker-hosting
- title: Deploy Docker Containers on Digital Ocean
- - url: https://docs.docker.com/reference/cli/docker/image/tag/
- title: Docker Tag
---
-The self-hosted deployment involves running your infrastructure locally or on a remote cloud server to host your application node.
+This guide explains how to run a Cartesi Rollups node locally on your machine for development and testing purposes on **testnet**.
-Here are the requirements:
+:::warning Production Warning
+**This self-hosted approach should NOT be used in *production*.**
-- Wallet with sufficient funds on the chosen network.
-- A cloud server
-- A PostgreSQL database
-- A web3 provider for interacting with the selected network
+While this setup works with testnet environments, it's designed exclusively for development purposes. It lacks critical production requirements such as:
## Initiating deployment
@@ -115,57 +102,95 @@ Fly.io is a platform where you can conveniently deploy applications packaged as
If deploying to Fly.io from macOS with Apple Silicon, create a Docker image for `linux/amd64` with: `cartesi deploy build --platform linux/amd64`
:::
-1. [Install the flyctl CLI](https://fly.io/docs/hands-on/install-flyctl/)
+## Prerequisites
-1. [Create an account](https://fly.io/docs/hands-on/sign-up-sign-in/)
+Before starting, ensure you have the following installed:
-1. Create an application:
+- Cartesi CLI: An easy-to-use tool for developing and deploying your dApps.
+
+- Docker Desktop 4.x: The required tool to distribute the Cartesi Rollups framework and its dependencies.
+
+For more details about the installation process for each of these tools, please refer to the [this section](../development/installation.md).
+
+## Configuration
+
+Before running the node, you need to configure your `.env` file with the following environment variables:
+
+```shell
+BLOCKCHAIN_ID=
+Before we begin writing the core components, make sure to configure _Cannon_ as your local chain in `wagmi.ts` file at the root of the project. This will make sure our web app is ready to interact with locally deployed Cartesi app.
-```javascript
-import { http, createConfig } from "wagmi";
-import {
- anvil,
- arbitrum,
- arbitrumGoerli,
- base,
- baseSepolia,
- mainnet,
- optimism,
- optimismGoerli,
- sepolia,
-} from "wagmi/chains";
-import { coinbaseWallet, injected, walletConnect } from "wagmi/connectors";
-import { createClient } from "viem";
+### 1. Configure the local environment
+Modify the existing `wagmi.ts` file with the code below. We add support for locally running with `cannon` network.
+```tsx
+import { http, createConfig } from 'wagmi'
+import { cannon, mainnet, sepolia } from 'wagmi/chains'
+import { coinbaseWallet, injected } from 'wagmi/connectors'
export const config = createConfig({
- chains: [
- anvil,
- mainnet,
- sepolia,
- arbitrum,
- arbitrumGoerli,
- optimismGoerli,
- optimism,
- base,
- baseSepolia,
- ],
+ chains: [cannon, mainnet, sepolia],
connectors: [
injected(),
coinbaseWallet(),
- walletConnect({ projectId: import.meta.env.VITE_WC_PROJECT_ID }),
],
- client({ chain }) {
- return createClient({ chain, transport: http() });
+ transports: {
+ [cannon.id]: http(),
+ [mainnet.id]: http(),
+ [sepolia.id]: http(),
},
-});
+})
-declare module "wagmi" {
+declare module 'wagmi' {
interface Register {
- config: typeof config;
+ config: typeof config
}
}
-
```
-
-
+```tsx
+import { CartesiProvider } from '@cartesi/wagmi';
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
+import { WagmiProvider } from 'wagmi';
+import { config } from '../wagmi';
-```jsx
-import { useAccount, useConnect, useDisconnect, useSwitchChain } from "wagmi";
-import { useState } from "react";
+const queryClient = new QueryClient();
-const Account = () => {
- const account = useAccount();
- const { connectors, connect, status, error } = useConnect();
- const { disconnect } = useDisconnect();
- const { chains, switchChain } = useSwitchChain();
- const [isChainDropdownOpen, setIsChainDropdownOpen] = useState(false);
+// Local Cartesi node RPC endpoint
+const CARTESI_RPC_URL = import.meta.env.VITE_CARTESI_RPC_URL || 'http://localhost:8080/rpc';
+export function Web3Provider({ children }: { children: React.ReactNode }) {
return (
-
-
- Account
-
-
-
- Status:
-
- {account.status.toLocaleUpperCase()}
-
-
- Address:{" "}
- {account.addresses?.[0]}
-
-
- Chain ID: {account.chain?.name} | {account.chainId}
-
-
+
+
+
+ {children}
+
+
+
+ );
+}
+```
- {/* Display chain switching and disconnect options when connected */}
- {account.status === "connected" && (
-
- {/* Chain switching dropdown */}
-
-
- {/* Dropdown menu for chain options */}
- {isChainDropdownOpen && (
-
- {chains.map((chainOption) => (
-
- ))}
-
- )}
-
- {/* Disconnect button */}
-
+### 3. Sending Inputs to Cartesi Application
+The `InputBox` contract is a trustless and permissionless contract that receives arbitrary blobs (called "inputs") from anyone. It is deployed on all supported chains. We will use `@cartesi/viem` library to send an input to the backend via the InputBox contract.
+
+Create `src/components/CartesiInput.tsx`:
+
+```tsx
+import { useState } from 'react';
+import { useAccount, useWalletClient } from 'wagmi';
+import { stringToHex, type Address } from 'viem';
+import { walletActionsL1 } from '@cartesi/viem';
+
+interface CartesiInputProps {
+ applicationAddress: Address;
+ }
+
+export function CartesiInput({ applicationAddress }: CartesiInputProps) {
+const [input, setInput] = useState('');
+const [isLoading, setIsLoading] = useState(false);
+const [txHash, setTxHash] = useState('');
+
+const { address } = useAccount();
+const { data: walletClient } = useWalletClient();
+
+const sendInput = async () => {
+ if (!walletClient || !address || !input.trim()) return;
+
+ setIsLoading(true);
+ setTxHash('');
+
+ try {
+ // Extend wallet client with Cartesi L1 actions
+ const extendedClient = walletClient.extend(walletActionsL1());
+
+ // Convert input string to hex
+ const payload = stringToHex(input);
+
+ // Send input to Cartesi application
+ const hash = await extendedClient.addInput({
+ account: address,
+ application: applicationAddress,
+ payload,
+ chain: walletClient.chain,
+ });
+
+ setTxHash(hash);
+ setInput('');
+
+ console.log('Input sent with transaction hash:', hash);
+ } catch (error) {
+ console.error('Failed to send input:', error);
+ } finally {
+ setIsLoading(false);
+ }
+};
+
+return (
+
+ Send Input
+
+
+
+
+ {txHash && (
+
+ ✅ Input sent successfully!
+ Transaction: {txHash}
- )}
+ )}
+);
+}
+```
+
+### 3. Reading Outputs from Cartesi Application
+Cartesi rollups node provides an RPC endpoint to fetch the outputs generated by an app. The component `CartesiOutputs` as shown below will list `Notices`, `Vouchers`, `Delegated Vouchers` and `Reports` on the UI.
+
+Create `src/components/CartesiOutputs.tsx`:
+
+```tsx
+import { useOutputs, useReports } from '@cartesi/wagmi';
+import { hexToString, type Address } from 'viem';
+
+interface CartesiOutputsProps {
+ applicationAddress: Address;
+ inputIndex?: number;
+}
+
+export function CartesiOutputs({ applicationAddress, inputIndex }: CartesiOutputsProps) {
+ const {
+ data: outputsData,
+ isLoading: outputsLoading,
+ error: outputsError,
+ refetch: refetchOutputs
+ } = useOutputs({
+ application: applicationAddress,
+ inputIndex: inputIndex ? BigInt(inputIndex) : undefined,
+ enabled: !!applicationAddress,
+ });
+
+ const {
+ data: reportsData,
+ isLoading: reportsLoading,
+ error: reportsError,
+ refetch: refetchReports
+ } = useReports({
+ application: applicationAddress,
+ inputIndex: inputIndex ? BigInt(inputIndex) : undefined,
+ enabled: !!applicationAddress,
+ });
- {/* Connect section */}
+ // Add logging for debugging
+ console.log('Reports Data:', reportsData);
+ console.log('Outputs Data:', outputsData);
+
+ const formatOutput = (output: any) => {
+ const { decodedData, index, inputIndex: outputInputIndex, epochIndex } = output;
+
+ // Convert BigInt to number for consistent handling
+ const indexNumber = typeof index === 'bigint' ? Number(index) : index;
+ const inputIndexNumber = typeof outputInputIndex === 'bigint' ? Number(outputInputIndex) : outputInputIndex;
+
+ if (!decodedData) {
+ return {
+ type: 'Unknown',
+ content: output.rawData || 'No data available',
+ index: indexNumber,
+ inputIndex: inputIndexNumber
+ };
+ }
+
+ switch (decodedData.type) {
+ case 'Notice':
+ return {
+ type: 'Notice',
+ content: decodedData.payload ? hexToString(decodedData.payload) : 'Empty payload',
+ index: indexNumber,
+ inputIndex: inputIndexNumber
+ };
+
+ case 'Voucher':
+ return {
+ type: 'Voucher',
+ content: `To: ${decodedData.destination} | Value: ${decodedData.value?.toString() || 'N/A'} | Payload: ${decodedData.payload || 'Empty'}`,
+ index: indexNumber,
+ inputIndex: inputIndexNumber
+ };
+
+ case 'DelegateCallVoucher':
+ return {
+ type: 'Delegate Call',
+ content: `To: ${decodedData.destination} | Payload: ${decodedData.payload || 'Empty'}`,
+ index: indexNumber,
+ inputIndex: inputIndexNumber
+ };
+
+ default:
+ return {
+ type: decodedData.type,
+ content: 'Unknown format',
+ index: indexNumber,
+ inputIndex: inputIndexNumber
+ };
+ }
+ };
+
+ const formatReport = (report: any) => {
+ console.log('Processing report:', report);
+
+ const { index, rawData, inputIndex, createdAt } = report;
+
+ // Convert BigInt to number for consistent handling
+ const indexNumber = typeof index === 'bigint' ? Number(index) : index;
+ const inputIndexNumber = typeof inputIndex === 'bigint' ? Number(inputIndex) : inputIndex;
+
+ let content = 'Empty report';
+
+ if (rawData) {
+ try {
+ console.log('Attempting to convert rawData:', rawData);
+ content = hexToString(rawData);
+ console.log('Converted content:', content);
+ } catch (error) {
+ console.log('Error converting rawData:', error);
+ content = `Raw: ${rawData}`;
+ }
+ } else {
+ console.log('No rawData found in report');
+ }
+
+ const formattedReport = {
+ type: 'Report',
+ content,
+ index: indexNumber,
+ inputIndex: inputIndexNumber,
+ createdAt: createdAt ? new Date(createdAt).toLocaleString() : 'Unknown'
+ };
+
+ return formattedReport;
+ };
+
+ if (outputsLoading || reportsLoading) return Loading...;
+ if (outputsError) return Error loading outputs: {outputsError.message};
+ if (reportsError) return Error loading reports: {reportsError.message};
+
+ // Combine and sort all outputs and reports
+ const allOutputs = [
+ ...(outputsData?.data?.map(formatOutput) || []),
+ ...(reportsData?.data?.map(formatReport) || [])
+ ].sort((a, b) => {
+ // Primary sort: by inputIndex (descending - latest input first)
+ const aInputIndex = Number(a.inputIndex);
+ const bInputIndex = Number(b.inputIndex);
+
+ if (aInputIndex !== bInputIndex) {
+ return bInputIndex - aInputIndex;
+ }
+
+ // Secondary sort: by output index (descending - latest output first within same input)
+ const aIndex = Number(a.index);
+ const bIndex = Number(b.index);
+ return bIndex - aIndex;
+ });
+
+ console.log('All combined outputs:', allOutputs);
+
+ return (
- Connect
-
- {connectors.map((connector) => (
-
- ))}
-
-
- Status: {status.toLocaleUpperCase()}
+
+ Application Outputs
+
-
- {error?.message}
+
+ {allOutputs.length === 0 ? (
+ No outputs found for this application.
+ ) : (
+
+
+
+ Input Index
+ Index
+ Type
+ Content
+
+
+
+ {allOutputs.map((output, idx) => (
+
+
+ {output.inputIndex !== undefined ? `#${output.inputIndex}` : 'N/A'}
+
+ #{output.index}
+
+ {output.type === 'Notice' && '📢 Notice'}
+ {output.type === 'Voucher' && '🎫 Voucher'}
+ {output.type === 'Delegate Call' && '🎫 Delegate Call'}
+ {output.type === 'Report' && '📊 Report'}
+ {output.type === 'Unknown' && '❓ Unknown'}
+
+
+ {output.content}
+
+
+ ))}
+
+
+ )}
+
+
+
+ Showing {allOutputs.length} outputs
+
-
-);
-};
-
-export default Account;
+ );
+}
```
-
-
+## Complete Example
-
-
+Stitch the components together inside the App.
-```javascript
-import Account from "./components/Account";
+Create `src/App.tsx`:
+
+```tsx
+import { useAccount, useConnect, useDisconnect } from 'wagmi'
+import { Web3Provider } from './providers/Web3Provider';
+import { CartesiInput } from './components/CartesiInput';
+import { CartesiOutputs } from './components/CartesiOutputs';
+import { type Address } from 'viem';
+
+// Get application address from environment variable
+const CARTESI_APP_ADDRESS = import.meta.env.VITE_CARTESI_APP_ADDRESS as Address;
+
+function CartesiApp() {
+ const { isConnected, address } = useAccount();
+ const { connectors, connect } = useConnect();
+ const { disconnect } = useDisconnect();
+
+ return (
+
+
+ 🐧 Cartesi App Frontend
+
+ {isConnected ? (
+
+ {address?.slice(0, 6)}...{address?.slice(-4)}
+
+
+ ) : (
+
+ {connectors.map((connector) => (
+
+ ))}
+
+ )}
+
+
+ {isConnected ? (
+
+
+ App Address: {CARTESI_APP_ADDRESS}
+
+
+ {/* Outputs Section */}
+
+
+
+
+ ) : (
+
+ Connect your wallet to interact with Cartesi application.
+
+ )}
+
+ );
+}
function App() {
return (
- <>
-
- >
+
+
+
);
}
-export default App;
+export default App
+```
+You're good to run the application and test sending inputs and list the corresponding outputs on the web UI.
+Run the web application locally:
+```
+pnpm dev
```
-
-
-
+## Bridging of Assets
+This section has other relevant components that can be plugged to the App as per the requirements.
+### Depositing Ether
+In this component, we use `depositEther()` function to bridge Ether from the base layer to the Cartesi rollups application.
-## Define the ABIs, contract addresses and hooks
+Create a `DepositEther.tsx` file in `src/components/` folder.
-In a Cartesi dApp, the frontend sends inputs to the backend via the base layer chain using JSON-RPC transactions.
+```tsx
+import { useState } from 'react';
+import { useAccount, useWalletClient } from 'wagmi';
+import { parseEther, toHex, type Address } from 'viem';
+import { walletActionsL1 } from '@cartesi/viem';
-Pre-deployed smart contracts on supported chains handle generic inputs and assets.
+interface DepositEtherProps {
+ applicationAddress: Address;
+}
-We only need their ABIs and addresses to send transactions using Wagmi.
+export function DepositEther({ applicationAddress }: DepositEtherProps) {
+ const [amount, setAmount] = useState('');
+ const [isLoading, setIsLoading] = useState(false);
+ const [txHash, setTxHash] = useState('');
-However, manually specifying the ABIs and addresses for all the Cartesi Rollups contracts when making function calls can be a hassle.
+ const { address } = useAccount();
+ const { data: walletClient } = useWalletClient();
-Thanks to [`@wagmi/cli`](https://wagmi.sh/cli/why), we can be more efficient by **autogenerating Cartesi-specific hooks**.
+ const handleDeposit = async () => {
+ if (!walletClient || !address || !amount || parseFloat(amount) <= 0) return;
-:::note
-These hooks come preconfigured with all the ABIs and addresses needed for any function calls to Cartesi. We just need to add the custom arguments for our specific use case.
-:::
+ setIsLoading(true);
+ setTxHash('');
+ try {
+ const valueInWei = parseEther(amount);
+ const data = toHex(`Deposited ${amount} ether`);
+
+ // Extend wallet client with Cartesi L1 actions
+ const cartesiWalletClient = walletClient.extend(walletActionsL1());
+
+ const hash = await cartesiWalletClient.depositEther({
+ application: applicationAddress,
+ value: valueInWei,
+ account: address,
+ execLayerData: data,
+ chain: walletClient.chain,
+ });
-This will automate manual work so we can build faster! We simply import the hooks, call the functions, and pass in the custom arguments.
+ setTxHash(hash);
+ setAmount('');
+ console.log('Deposit sent with transaction hash:', hash);
+ } catch (error) {
+ console.error('Failed to deposit:', error);
+ } finally {
+ setIsLoading(false);
+ }
+ };
-We will install the following dependencies to our project:
+ return (
+
+ Deposit Ether
+
+
+
+ setAmount(e.target.value)}
+ disabled={isLoading}
+ />
+
-- [`@wagmi/cli`](https://wagmi.sh/cli/why): The Wagmi CLI tool for ABI-specific hooks.
-- [`@cartesi/rollups`](https://www.npmjs.com/package/@cartesi/rollups): The Cartesi Rollups contract implementations.
-- [`@sunodo/wagmi-plugin-hardhat-deploy`](https://www.npmjs.com/package/@sunodo/wagmi-plugin-hardhat-deploy): Wagmi CLI plugin that loads contracts and deployments from the `@cartesi/rollups` package.
+
-```bash
-npm i @wagmi/cli @cartesi/rollups @sunodo/wagmi-plugin-hardhat-deploy
+ {txHash && (
+
+ ✅ Deposit sent successfully!
+ Transaction: {txHash}
+
+ )}
+
+ );
+}
```
+## Advanced Usage
+### Waiting for Input Processing
-Create a config file in the root of your project: `wagmi.config.ts`
+```tsx
+import { useWaitForInput } from '@cartesi/wagmi';
-Then, add contracts and plugins for Cartesi Rollups:
+function InputTracker({ applicationAddress, inputIndex }: {
+ applicationAddress: string;
+ inputIndex: number;
+}) {
+ const { data: input, isLoading } = useWaitForInput({
+ application: applicationAddress,
+ inputIndex,
+ enabled: !!applicationAddress && inputIndex !== undefined,
+ });
-
+ if (isLoading) return ⏳ Waiting for input to be processed...;
-
-
+ return (
+
+ ✅ Input #{inputIndex} processed with status: {input?.status}
+
+ );
+}
+```
-```typescript
-import { defineConfig } from "@wagmi/cli";
-import { react } from "@wagmi/cli/plugins";
-import { erc20Abi, erc721Abi } from "viem";
-import hardhatDeploy from "@sunodo/wagmi-plugin-hardhat-deploy";
-
-export default defineConfig({
- out: "src/hooks/generated.ts", // Specifies the output file for the hooks
- contracts: [
- {
- abi: erc20Abi,
- name: "erc20",
- },
- { abi: erc721Abi, name: "erc721" },
- ],
- plugins: [
- hardhatDeploy({
- directory: "node_modules/@cartesi/rollups/export/abi",
- }),
- react(),
-],
+### Using Low-level RPC Client
+
+```tsx
+import { createClient } from '@cartesi/rpc';
+
+const rpcClient = createClient({
+ uri: 'http://localhost:8080/rpc',
+});
+
+// Use RPC client directly
+const outputs = await rpcClient.request('cartesi_listOutputs', {
+ application: '0x...',
+ limit: 10,
+ offset: 0,
});
```
-
-
+### Listing all available applications
+Create `src/components/CartesiApps.ts`:
-
+```tsx
+import { useApplications } from '@cartesi/wagmi';
+import { useState, useEffect } from 'react';
+import { type Address } from 'viem';
The configuration sets up the Wagmi CLI to generate TypeScript hooks for ERC20 and ERC721 contracts, as well as for any contracts in the specified Cartesi Rollups ABI directory, i.e `src/hooks/generated`.
@@ -674,191 +966,52 @@ Here are the key differences in depositing ERC20 tokens compared to Ether:
:::note ERC Token Approval
For [**ERC20, ERC721, and ERC1155 token standards**](https://ethereum.org/en/developers/docs/standards/tokens/), an approval step is need. This ensures you grant explicit permission for a contract (like the Portals) to transfer tokens on your behalf.
- Without this approval, contracts like ERC20Portal cannot move your tokens to the Cartesi backend.
- :::
-
- - We will use the `useWriteErc20Approve` hook to approve the deposit and `useWriteErc20PortalDepositErc20Tokens` hook to make the deposit.
-
- ```typescript
- import {
- erc20PortalAddress,
- useWriteErc20Approve,
- useWriteErc20PortalDepositErc20Tokens,
- } from "../hooks/generated";
-
- import { Address, parseEther, stringToHex, Hex } from "viem";
-
- // other imports here
-
- const [erc20Value, setErc20Value] = useState("");
- const [tokenAddress, setTokenAddress] = useState();
-
- const { writeContractAsync: approveToken } = useWriteErc20Approve();
- const { writeContractAsync: depositToken} = useWriteErc20PortalDepositErc20Token();
-
- const approve = async (address: Address, amount: string) => {
- try {
- await approveToken({
- address,
- args: [erc20PortalAddress, parseEther(amount)],
- });
- console.log("ERC20 Approval successful");
- } catch (error) {
- console.error("Error in approving ERC20:", error);
- throw error;
- }
- };
+ const {
+ data: applicationsData,
+ isLoading: isLoadingApps,
+ error: appsError
+ } = useApplications({});
- async function submit(event: React.FormEvent) {
- event.preventDefault();
- const data = stringToHex(`Deposited (${erc20Value}).`);
- await approve(tokenAddress as Address, erc20Value);
- await depositToken({
- args: [tokenAddress as Hex, dAppAddress, parseEther(erc20Value), data],
- });
+ // Auto-select first application if available
+ useEffect(() => {
+ if (applicationsData?.data?.length && !selectedApp) {
+ const firstApp = applicationsData.data[0].applicationAddress;
+ setSelectedApp(firstApp);
+ onAppSelect?.(firstApp as Address);
}
+ }, [applicationsData, selectedApp, onAppSelect]);
- // rest of the code
-
- ```
-
-For testing purposes, you'll need to deploy a test ERC20 token. Follow [this simple guide to deploy a test ERC20 token and add it to your Metamask wallet](https://www.michaelasiedu.dev/posts/deploy-erc20-token-on-localhost/).
-
-
-### Final Component
-
-Create a new file `src/components/SendERC20.tsx` and paste the complete code:
-
-
-
-
-
-```jsx
-import React, { useState } from "react";
-import { BaseError } from "wagmi";
-import {
- erc20PortalAddress,
- useWriteErc20Approve,
- useWriteErc20PortalDepositErc20Tokens,
-} from "../hooks/generated";
-import { Address, parseEther, stringToHex, Hex } from "viem";
-
-const SendERC20 = () => {
- const dAppAddress = `0xab7528bb862fb57e8a2bcd567a2e929a0be56a5e`;
- const [erc20Value, setErc20Value] = useState("");
- const [tokenAddress, setTokenAddress] = useState();
-
- const {
- isPending,
- isSuccess,
- error,
- writeContractAsync: depositToken,
- } = useWriteErc20PortalDepositErc20Tokens();
-
- const { writeContractAsync: approveToken } = useWriteErc20Approve();
-
- const approve = async (address: Address, amount: string) => {
- try {
- await approveToken({
- address,
- args: [erc20PortalAddress, parseEther(amount)],
- });
- console.log("ERC20 Approval successful");
- } catch (error) {
- console.error("Error in approving ERC20:", error);
- throw error;
- }
+ const handleAppChange = (appAddress: string) => {
+ setSelectedApp(appAddress);
+ onAppSelect?.(appAddress as Address);
};
- async function submit(event: React.FormEvent) {
- event.preventDefault();
- const data = stringToHex(`Deposited (${erc20Value}).`);
- await approve(tokenAddress as Address, erc20Value);
- await depositToken({
- args: [tokenAddress as Hex, dAppAddress, parseEther(erc20Value), data],
- });
- }
+ if (isLoadingApps) return Loading applications...;
+ if (appsError) return Error loading applications: {appsError.message};
return (
-
- Deposit ERC20
-