Docs
Reference
Contract documentation
L1
TaikoL1Base

TaikoL1Base

This contract serves as the "base layer contract" of the Taiko protocol, providing functionalities for proposing, proving, and verifying blocks. The term "base layer contract" means that although this is usually deployed on L1, it can also be deployed on L2s to create L3s ("inception layers"). The contract also handles the deposit and withdrawal of Taiko tokens and Ether.

state

struct TaikoData.State state

receive

receive() external payable

Fallback function to receive Ether and deposit to to Layer 2.

init

function init(address _addressManager, bytes32 _genesisBlockHash) external

Initializes the rollup.

Parameters

NameTypeDescription
_addressManageraddressThe {AddressManager} address.
_genesisBlockHashbytes32The block hash of the genesis block.

proposeBlock

function proposeBlock(bytes input, bytes assignment, bytes txList) external payable returns (struct TaikoData.BlockMetadata meta)

Proposes a Taiko L2 block.

Parameters

NameTypeDescription
inputbytesAn abi-encoded BlockMetadataInput that the actual L2 block header must satisfy.
assignmentbytesData to assign a prover.
txListbytesA list of transactions in this block, encoded with RLP. Note, in the corresponding L2 block an "anchor transaction" will be the first transaction in the block. If there are n transactions in the txList, then there will be up to n + 1 transactions in the L2 block.

Return Values

NameTypeDescription
metastruct TaikoData.BlockMetadataThe metadata of the proposed L2 block.

proveBlock

function proveBlock(uint64 blockId, bytes input) external

Proves a block with a zero-knowledge proof.

Parameters

NameTypeDescription
blockIduint64The index of the block to prove. This is also used to select the right implementation version.
inputbytesAn abi-encoded {TaikoData.BlockEvidence} object.

verifyBlocks

function verifyBlocks(uint64 maxBlocks) external

Verifies up to N blocks.

Parameters

NameTypeDescription
maxBlocksuint64Max number of blocks to verify.

depositTaikoToken

function depositTaikoToken(uint256 amount) external

Deposits Taiko tokens to the contract.

Parameters

NameTypeDescription
amountuint256Amount of Taiko tokens to deposit.

withdrawTaikoToken

function withdrawTaikoToken(uint256 amount) external

Withdraws Taiko tokens from the contract.

Parameters

NameTypeDescription
amountuint256Amount of Taiko tokens to withdraw.

depositEtherToL2

function depositEtherToL2(address recipient) public payable

Deposits Ether to Layer 2.

Parameters

NameTypeDescription
recipientaddressAddress of the recipient for the deposited Ether on Layer 2.

getTaikoTokenBalance

function getTaikoTokenBalance(address addr) public view returns (uint256)

Gets the Taiko token balance for a specific address.

Parameters

NameTypeDescription
addraddressAddress to check the Taiko token balance.

Return Values

NameTypeDescription
[0]uint256The Taiko token balance of the address.

canDepositEthToL2

function canDepositEthToL2(uint256 amount) public view returns (bool)

Checks if Ether deposit is allowed for Layer 2.

Parameters

NameTypeDescription
amountuint256Amount of Ether to be deposited.

Return Values

NameTypeDescription
[0]booltrue if Ether deposit is allowed, false otherwise.

getBlock

function getBlock(uint64 blockId) public view returns (struct TaikoData.Block blk)

Gets the details of a block.

Parameters

NameTypeDescription
blockIduint64Index of the block.

Return Values

NameTypeDescription
blkstruct TaikoData.BlockThe block.

getTransition

function getTransition(uint64 blockId, bytes32 parentHash) public view returns (struct TaikoData.Transition)

Gets the state transition for a specific block.

Parameters

NameTypeDescription
blockIduint64Index of the block.
parentHashbytes32Parent hash of the block.

Return Values

NameTypeDescription
[0]struct TaikoData.TransitionThe state transition data of the block.

getCrossChainBlockHash

function getCrossChainBlockHash(uint64 blockId) public view returns (bytes32)

Fetches the hash of a block from the opposite chain.

Parameters

NameTypeDescription
blockIduint64The target block id. Specifying 0 retrieves the hash of the latest block.

Return Values

NameTypeDescription
[0]bytes32The hash of the desired block from the other chain.

getCrossChainSignalRoot

function getCrossChainSignalRoot(uint64 blockId) public view returns (bytes32)

Retrieves the root hash of the signal service storage for a given block from the opposite chain.

Parameters

NameTypeDescription
blockIduint64The target block id. Specifying 0 retrieves the root of the latest block.

Return Values

NameTypeDescription
[0]bytes32The root hash for the specified block's signal service.

getStateVariables

function getStateVariables() public view returns (struct TaikoData.StateVariables)

Gets the state variables of the TaikoL1 contract.

Return Values

NameTypeDescription
[0]struct TaikoData.StateVariablesStateVariables struct containing state variables.

getVerifierName

function getVerifierName(uint16 id) public pure returns (bytes32)

Gets the name of the proof verifier by ID.

Parameters

NameTypeDescription
iduint16ID of the verifier.

Return Values

NameTypeDescription
[0]bytes32Verifier name.

getConfig

function getConfig() public pure virtual returns (struct TaikoData.Config)

Gets the configuration of the TaikoL1 contract.

Return Values

NameTypeDescription
[0]struct TaikoData.ConfigConfig struct containing configuration parameters.