Skip to main content

API Reference

DaveConsensus Contract


canSettle()

function canSettle() external view returns (bool isFinished, uint256 epochNumber, Tree.Node winnerCommitment)

Check if the current epoch can be settled by querying the tournament's arbitration result.

Returns:

NameTypeDescription
isFinishedboolWhether tournament is finished
epochNumberuint256Current epoch number
winnerCommitmentTree.NodeWinner's commitment from tournament

settle()

function settle(uint256 epochNumber, bytes32 outputsMerkleRoot, bytes32[] calldata proof) external

Settle an epoch using tournament results and create a new tournament for the next epoch.

Parameters:

NameTypeDescription
epochNumberuint256The epoch number to settle
outputsMerkleRootbytes32Root hash of the outputs Merkle tree
proofbytes32[]Merkle proof array for validation

getCurrentSealedEpoch()

function getCurrentSealedEpoch() external view returns (uint256 epochNumber, uint256 inputIndexLowerBound, uint256 inputIndexUpperBound, ITournament tournament)

Get information about the current sealed epoch including bounds and tournament.

Returns:

NameTypeDescription
epochNumberuint256Current epoch number
inputIndexLowerBounduint256Lower bound of input indices (inclusive)
inputIndexUpperBounduint256Upper bound of input indices (exclusive)
tournamentITournamentCurrent tournament contract

isOutputsMerkleRootValid()

function isOutputsMerkleRootValid(address appContract, bytes32 outputsMerkleRoot) public view override returns (bool)

Validate whether a given outputs Merkle root is valid for the specified application.

Parameters:

NameTypeDescription
appContractaddressApplication contract address to validate against
outputsMerkleRootbytes32Outputs Merkle root hash to validate

Returns:

NameTypeDescription
validboolWhether the outputs Merkle root is valid

provideMerkleRootOfInput()

function provideMerkleRootOfInput(uint256 inputIndexWithinEpoch, bytes calldata input) external view override returns (bytes32)

Get the Merkle root for input data at a specific index within the current epoch.

Parameters:

NameTypeDescription
inputIndexWithinEpochuint256Index of input within the current epoch
inputbytesInput data bytes to process

Returns:

NameTypeDescription
merkleRootbytes32Merkle root of the input data

DaveConsensusFactory Contract


newDaveConsensus()

function newDaveConsensus(address appContract, Machine.Hash initialMachineStateHash) external returns (DaveConsensus)

Deploy a new DaveConsensus contract instance for an application.

Parameters:

NameTypeDescription
appContractaddressApplication contract address
initialMachineStateHashMachine.HashInitial state hash of the Cartesi machine

Returns:

NameTypeDescription
daveConsensusDaveConsensusDeployed DaveConsensus contract instance

newDaveConsensus() (with salt)

function newDaveConsensus(address appContract, Machine.Hash initialMachineStateHash, bytes32 salt) external returns (DaveConsensus)

Deploy a new DaveConsensus contract with deterministic address using CREATE2.

Parameters:

NameTypeDescription
appContractaddressApplication contract address
initialMachineStateHashMachine.HashInitial state hash of the Cartesi machine
saltbytes32Salt for CREATE2 deterministic deployment

Returns:

NameTypeDescription
daveConsensusDaveConsensusDeployed DaveConsensus contract instance

calculateDaveConsensusAddress()

function calculateDaveConsensusAddress(address appContract, Machine.Hash initialMachineStateHash, bytes32 salt) external view returns (address)

Calculate the deployment address for a DaveConsensus contract before deployment.

Parameters:

NameTypeDescription
appContractaddressApplication contract address
initialMachineStateHashMachine.HashInitial state hash of the Cartesi machine
saltbytes32Salt for CREATE2 address calculation

Returns:

NameTypeDescription
addressaddressCalculated deployment address
We use cookies to ensure that we give you the best experience on our website. By using the website, you agree to the use of cookies.