Intelligent Contracts
Tooling Setup

Tooling Setup

This guide will help you set up the GenLayer environment by installing the GenLayer CLI and launching the GenLayer Studio.

Table of Contents

  1. Using the GenLayer Studio
  2. Installation of the GenLayer CLI
  3. Launching the GenLayer Simulator
  4. Writing Intelligent Contracts
  5. Deploying and Interacting with Intelligent Contracts

Using the GenLayer Studio

The GenLayer Studio is a web-based interface for developing, testing, and deploying Intelligent Contracts. It provides a user-friendly environment for interacting with the GenLayer ecosystem. You can find it at studio.genlayer.com (opens in a new tab).

Local Installation of the GenLayer CLI

The GenLayer CLI is used to set up the GenLayer Studio and, in the future, mainnet and testnet environments.

Prerequisites

Ensure you have the following installed and updated:


Installation Steps

  1. Install GenLayer CLI

    Open your terminal and run:

    npm install -g genlayer
  2. Initialize GenLayer Environment

    Run the following command to set up your development environment:

    genlayer init

    During initialization, you'll be prompted to select your preferred LLM provider(s) and enter any required API keys.

    Optional Initialization Parameters

    You can customize the initialization with the following options:

    • --numValidators <number>: Specify the number of validators (default is 5)
    • --headless: Run in headless mode without UI (default is false)
    • --reset-db: Reset the database to a clean state (default is false)
    • --localnet-version <version>: Specify the localnet version to use (default is latest stable version)

    Example:

    genlayer init --numValidators 3 --headless --reset-db --localnet-version v0.32.1

Launching the GenLayer Studio

After initializing the environment, you can start the Studio by running:

genlayer up

This command launches the GenLayer Studio using your existing configuration.

Optional Parameters:

  • --reset-validators: Removes all current validators and creates new ones.
  • --numValidators <number>: Specify the number of validators to start.
  • --headless: Run in headless mode without UI (default is false)
  • --reset-db: Reset the database to a clean state (default is false)

Example:

genlayer up --reset-validators --numValidators 3 --headless --reset-db

Once the Studio is running, access it at http://localhost:8080/ (opens in a new tab).

Writing Intelligent Contracts

Refer to the Your First Contract page for more information on how to write Intelligent Contracts.

Deploying and Interacting with Intelligent Contracts

Deploying the Contract

  1. Load Your Contract
    In the GenLayer Studio, navigate to the Contracts section and upload your contract file.

  2. Deploy the Contract
    Navigate to the Run and Deploy section and click the "Deploy" button.
    The Studio will automatically detect constructor parameters. Provide the required values.
    Upon successful deployment, the contract address will be displayed.

Interacting with the Contract

  1. Read Methods
    View the current state of the contract using Read Methods. These are methods that return data without modifying the state.

  2. Write Methods
    Execute Write Methods to interact with your contract. Provide any required input parameters.

  3. Execution Logs
    Monitor transactions and validator consensus via the Node Logs at the bottom of the Studio.

  4. Transaction Details
    View detailed information about a transaction by clicking on it in the bottom left list of transactions.