Skip to main content

Submitting a Block to Ethereum

View as Markdown

Rollup blocks are submitted to the host chain by calling the Zenith submitBlock function, attaching transaction data in a 4844 blob.

Code Flows

These examples assume one has already chosen a set of transactions and bundles, and gotten a co-signature from the Sequencer API.

Creating the Blob Transaction

  1. Transform the SignResponse into a Zenith::BlockHeader.

    let header = Zenith::BlockHeader {
        hostBlockNumber: resp.req.host_block_number,
        rollupChainId: U256::from(self.config.ru_chain_id),
        gasLimit: resp.req.gas_limit,
        rewardAddress: resp.req.ru_reward_address,
        blockDataHash: in_progress.contents_hash(),
    };
  2. Encode the submitBlock transaction data from the BlockHeader & the Sequencer’s Signature from the SignResponse

    let data = Zenith::submitBlockCall { header, v, r, s, _4: Default::default() }.abi_encode();
  3. Encode the transactions into a 4844 blob sidecar containing the rlp-encoded transactions.

    pub fn encode_blob(&self) -> SidecarBuilder<SimpleCoder> {
        let mut coder = SidecarBuilder::default();
        coder.ingest(self.encode_raw());
        coder
    }
  4. Attach the blob sidecar to a TransactionRequest.

    let tx = TransactionRequest::default().with_blob_sidecar(sidecar).with_input(data);
  5. Fill in remaining transaction details (including the calldata, which must contain the encoded submitBlockCall above).

  6. Submit the constructed transaction to Ethereum.

Start typing to search documentation...