🩷Taiko

Guide to Setting Up and Using Taiko Client from the Taiko-Mono Repository


Prerequisites

Ensure you have the following installed:

  • Node.js (v16 or later)

  • Yarn (preferred package manager)

  • Docker (optional, for running dependencies like Ethereum nodes locally)

Clone the repository:

git clone https://github.com/taikoxyz/taiko-mono.git
cd taiko-mono/packages/taiko-client

Installation

  1. Install Dependencies

    Run the following commands to install dependencies for the taiko-client package:

    cd taiko-client
    yarn install
  2. Environment Configuration

    Create a .env file in the taiko-client directory and configure the following environment variables:

    RPC_URL=<Your Layer 1 RPC URL>
    L2_RPC_URL=<Your Layer 2 RPC URL>
    PRIVATE_KEY=<Your private key for submitting transactions>

    Replace:

    • <Your Layer 1 RPC URL> with the Ethereum RPC endpoint (e.g., Infura or Alchemy).

    • <Your Layer 2 RPC URL> with the Layer 2 RPC endpoint.

    • <Your private key> with your Ethereum private key (be cautious about securing it).


Running the Client

The Taiko client provides different modes of operation. Below are the most common:

  1. Start the Prover

    To start the prover, which validates Layer 2 blocks:

    This command will:

    • Monitor Layer 1 and Layer 2 chains for new events.

    • Validate transactions and blocks.

  2. Start the Block Producer

    To start the block producer, which submits Layer 2 blocks to Layer 1:

    This ensures your Layer 2 blocks are included in the Layer 1 chain.

  3. Run Tests

    The taiko-client comes with built-in tests to ensure proper functionality. To run tests:


Code Overview

The taiko-client codebase has several key components:

  • src/index.ts: Entry point for the client.

  • src/prover.ts: Logic for block validation and proving.

  • src/producer.ts: Handles block production and submission to Layer 1.

  • src/events.ts: Listens for events on the Layer 1 and Layer 2 chains.

  • src/config.ts: Centralized configuration file for environment variables and constants.

Example: Listening to Blockchain Events

You can listen to blockchain events using the ethers library. Below is a simple example:

Example: Submitting Transactions

To submit a transaction to Layer 1:


Debugging

  1. Enable Debug Logs

    Use the DEBUG environment variable to enable detailed logging:

  2. Common Issues

    • Ensure your .env file is correctly configured.

    • Verify that your RPC URLs are accessible.

    • Check for any Ethereum account or private key issues.


Last updated