Address Contract Verified
Address
0xc70074BDD26d8cF983Ca6A5b89b8db52D5850051
Balance
0 ETH
Nonce
1
Code Size
835 bytes
Creator
Create2 Deployer at tx 0xc2381ee5...b55edc
Indexed Transactions
0
Contract Bytecode
835 bytes
0x6080806040526004361015610012575f80fd5b5f3560e01c9081631789cd63146101055750806361a93c87146100ce578063677087c9146100865763b3a1acd814610048575f80fd5b34610082575f3660031901126100825760206040517f000000000000000000000000000000000000000000000000000000000158c8c08152f35b5f80fd5b34610082576040366003190112610082576001600160a01b036100a76102ce565b165f525f60205260206100bf60243560405f206102e4565b90549060031b1c604051908152f35b34610082576020366003190112610082576001600160a01b036100ef6102ce565b165f525f602052602060405f2054604051908152f35b346100825760403660031901126100825761011e6102ce565b6024359067ffffffffffffffff821161008257366023830112156100825781600401359067ffffffffffffffff82116100825736602483850101116100825760018060a01b0316805f525f60205260405f209361014481865494806024602084019863415bf36360e01b8a5246828601528760448601523360648601524360848601524260a48601524460c48601528860e48601526101006101048601528261012486015201848401375f838284010152601f801991011681010301601f1981018252601f8019910116810181811067ffffffffffffffff82111761029d5760405280516201000081116102b1575080518420936801000000000000000084101561029d5760407fc05d337121a6e8605c6ec0b72aa29c4210ffe6e5b9cefdd6a7058188a8f66f9892610259866020996001820181556102e4565b81549060031b9089821b915f19901b19161790558151928391898352518091818b8501528484015e5f828201840152601f01601f19168101030190a3604051908152f35b634e487b7160e01b5f52604160045260245ffd5b826304f90dc560e51b5f526004526024526201000060445260645ffd5b600435906001600160a01b038216820361008257565b80548210156102f9575f5260205f2001905f90565b634e487b7160e01b5f52603260045260245ffdfea26469706673582212206be6848ff6e064f9d971312786de764ea83b1b162939a0e3b844b2a06bd553ed64736f6c634300081d0033
Verified Source Code Full Match
Compiler: v0.8.29+commit.ab55807c
EVM: cancun
Optimization: Yes (200 runs)
CanonicalMachine.sol 16 lines
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)
pragma solidity ^0.8.8;
/// @title Canonical Machine Constants Library
///
/// @notice Defines several constants related to the reference implementation
/// of the RISC-V machine that runs Linux, also known as the "Cartesi Machine".
library CanonicalMachine {
/// @notice Maximum input size (64 kilobytes).
uint256 constant INPUT_MAX_SIZE = 1 << 16;
/// @notice Log2 of maximum number of outputs.
uint256 constant LOG2_MAX_OUTPUTS = 63;
}
Inputs.sol 29 lines
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)
pragma solidity ^0.8.8;
/// @title Inputs
/// @notice Defines the signatures of inputs.
interface Inputs {
/// @notice An advance request from an EVM-compatible blockchain to a Cartesi Machine.
/// @param chainId The chain ID
/// @param appContract The application contract address
/// @param msgSender The address of whoever sent the input
/// @param blockNumber The number of the block in which the input was added
/// @param blockTimestamp The timestamp of the block in which the input was added
/// @param prevRandao The latest RANDAO mix of the post beacon state of the previous block
/// @param index The index of the input in the input box
/// @param payload The payload provided by the message sender
/// @dev See EIP-4399 for safe usage of `prevRandao`.
function EvmAdvance(
uint256 chainId,
address appContract,
address msgSender,
uint256 blockNumber,
uint256 blockTimestamp,
uint256 prevRandao,
uint256 index,
bytes calldata payload
) external;
}
IInputBox.sol 48 lines
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)
pragma solidity ^0.8.8;
/// @notice Provides data availability of inputs for applications.
/// @notice Each application has its own append-only list of inputs.
/// @notice Off-chain, inputs can be retrieved via events.
/// @notice On-chain, only the input hashes are stored.
/// @notice See `LibInput` for more details on how such hashes are computed.
interface IInputBox {
/// @notice MUST trigger when an input is added.
/// @param appContract The application contract address
/// @param index The input index
/// @param input The input blob
event InputAdded(address indexed appContract, uint256 indexed index, bytes input);
/// @notice Input is too large.
/// @param appContract The application contract address
/// @param inputLength The input length
/// @param maxInputLength The maximum input length
error InputTooLarge(address appContract, uint256 inputLength, uint256 maxInputLength);
/// @notice Send an input to an application.
/// @param appContract The application contract address
/// @param payload The input payload
/// @return The hash of the input blob
/// @dev MUST fire an `InputAdded` event.
function addInput(address appContract, bytes calldata payload)
external
returns (bytes32);
/// @notice Get the number of inputs sent to an application.
/// @param appContract The application contract address
function getNumberOfInputs(address appContract) external view returns (uint256);
/// @notice Get the hash of an input in an application's input box.
/// @param appContract The application contract address
/// @param index The input index
/// @dev The provided index must be valid.
function getInputHash(address appContract, uint256 index)
external
view
returns (bytes32);
/// @notice Get number of block in which contract was deployed
function getDeploymentBlockNumber() external view returns (uint256);
}
InputBox.sol 80 lines
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)
pragma solidity ^0.8.18;
import {IInputBox} from "./IInputBox.sol";
import {CanonicalMachine} from "../common/CanonicalMachine.sol";
import {Inputs} from "../common/Inputs.sol";
contract InputBox is IInputBox {
/// @notice Deployment block number
uint256 immutable _deploymentBlockNumber = block.number;
/// @notice Mapping of application contract addresses to arrays of input hashes.
mapping(address => bytes32[]) private _inputBoxes;
/// @inheritdoc IInputBox
function addInput(address appContract, bytes calldata payload)
external
override
returns (bytes32)
{
bytes32[] storage inputBox = _inputBoxes[appContract];
uint256 index = inputBox.length;
bytes memory input = abi.encodeCall(
Inputs.EvmAdvance,
(
block.chainid,
appContract,
msg.sender,
block.number,
block.timestamp,
block.prevrandao,
index,
payload
)
);
if (input.length > CanonicalMachine.INPUT_MAX_SIZE) {
revert InputTooLarge(
appContract, input.length, CanonicalMachine.INPUT_MAX_SIZE
);
}
bytes32 inputHash = keccak256(input);
inputBox.push(inputHash);
emit InputAdded(appContract, index, input);
return inputHash;
}
/// @inheritdoc IInputBox
function getNumberOfInputs(address appContract)
external
view
override
returns (uint256)
{
return _inputBoxes[appContract].length;
}
/// @inheritdoc IInputBox
function getInputHash(address appContract, uint256 index)
external
view
override
returns (bytes32)
{
return _inputBoxes[appContract][index];
}
/// @inheritdoc IInputBox
function getDeploymentBlockNumber() external view override returns (uint256) {
return _deploymentBlockNumber;
}
}
Read Contract
getDeploymentBlockNumber 0xb3a1acd8 → uint256
getInputHash 0x677087c9 → bytes32
getNumberOfInputs 0x61a93c87 → uint256
Write Contract 1 functions
These functions modify contract state and require a wallet transaction to execute.
addInput 0x1789cd63
address appContract
bytes payload
returns: bytes32
Recent Transactions
No transactions found for this address