LogoLogo
  • Guide to Developing on Layer One X
    • Contents
    • L1X vs. Other Chains
    • L1X Technology Overview
      • X-Talk Overview
      • L1X System Architecture
      • XTalk Deep Dive
  • L1X Documentation
    • Setup L1X Development Environment
  • Use Cases
    • Use Case 1: Decentralised Finance (DeFi)
      • Key Components and Protocols
      • Use Case Implementation Examples
      • Future Trends and Innovations
    • Use Case 2: Non-Fungible Tokens (NFTs)
      • Applications in Art, Gaming, and Collectibles
      • Use Case Examples and Case Studies
      • Emerging Trends in NFTs
    • Use Case 3: Identity Management
      • Importance of Self-Sovereign Identity
      • Use Cases in Identity Verification and Authentication
      • Projects and Initiatives in Identity Management
      • Privacy and Security Considerations
    • Use Case 4: Content Monetisation
      • Challenges in Content Monetisation
      • Blockchain Solutions for Micropayments and Royalties
      • Use Case Examples in Publishing, Music, and Media
      • Future Opportunities and Trends
    • Use Case 5: Voting and Governance
      • Advantages of Blockchain in Voting Systems
      • Use Cases in Elections, Polls, and Governance
      • Projects and Platforms for Decentralised Voting
      • Challenges and Considerations
    • Use Case 6: Decentralised Storage
      • Problems with Centralised Storage Solutions
      • Use Cases in Decentralised File Storage
      • Projects and Platforms for Decentralised Storage
      • Scalability and Performance Challenges
    • Use Case 7: Gaming and Virtual Worlds
      • Introduction to Blockchain Gaming
      • Use Cases in Virtual Economies, Assets, and Ownership
      • Notable Projects and Success Stories
      • Trends and Innovations in Blockchain Gaming
    • Use Case 8: Healthcare and Medical Records
      • Importance of Data Integrity and Security in Healthcare
      • Use Cases in Medical Records Management
      • Projects and Initiatives in Health Data Management
      • Regulatory Compliance and Privacy Concerns
    • Use Case 9: Decentralised Autonomous Organisations (DAOs)
      • Understanding DAOs
      • Use Cases in Governance, Funding, and Decision Making
      • Future Developments
    • Use Case 10: Supply Chain Management
      • Overview of Supply Chain Challenges
      • Blockchain Solutions in Supply Chain
      • Use Case Examples in Tracking and Traceability
      • Potential Benefits and Challenges
  • Get Started with L1X SDE
    • L1X Workspace Overview
      • L1X SDE toolkit architecture
    • Development Workspace Environment & Contract Types
      • 1 - Contemporary Contracts
      • 2 - ERC20 Contract Deployment and Cross Contract Call
      • 3 - X-Talk Flow Cross Chain Contract
      • 4 - Balancer-v2
  • Build with Developer Playground
    • Developer Playground Resource
  • Core Concepts
    • Account
    • Address
    • Transaction
    • Smart Contract
    • Contract Lifecycle (VM)
    • Cross-Contract call
      • L1X VM Cross-Contract Calls
      • L1X VM-EVM Cross Contract Calls
    • Cluster
Powered by GitBook
On this page
  1. L1X Documentation

Setup L1X Development Environment

PreviousL1X DocumentationNextUse Cases

Last updated 1 year ago

Check the Video version of the Setup

Before you start using L1X SDE, make sure you have the following prerequisites installed on your system:

Note: The current version of L1X SDE is compatible with the following Host OS: Linux | MacOS | Windows (WSL2)

  • Rust and Cargo

    • You can follow the installation guide: to install Rust and Cargo.

    • To install Rust and Cargo, run the command below in your terminal:

      curl https://sh.rustup.rs -sSf | sh
  • ProtoBuff

    sudo apt-get install protobuf

  • Devbox

    • Devbox is required for using L1X SDE. You can find the installation guide: to set up Devbox.

    • To install Devbox, run the command below in your terminal:

      curl -fsSL https://get.jetpack.io/devbox | bash
    • Devbox also needs the Nix Package Manager. If your system doesn't have Nix installed, Devbox will automatically install it for you with the default settings for your operating system.

  • Docker Engine & docker-compose

    • Docker Engine & docker-compose is essential for running L1X SDE Local Devnet. You can follow the installation guide: to set up Docker Engine & docker-compose on your system.

    • Additionally, ensure that you can run the Docker daemon as a non-root user by adding user to Docker group.

      • Create a docker group if there isn’t one:

        sudo groupadd docker
      • Add your user to the docker group:

        sudo usermod -aG docker $USER
      • Log out and log back in so that your group membership is re-evaluated.

    • To verify Docker installation, run the command below in your terminal:

      $ docker run --rm hello-world

      If Docker is installed correctly, you should see a message confirming that the installation is working.

       Hello from Docker!
      
       This message shows that your installation appears to be working correctly ...
  • l1x-forge

    • l1x-forge is a smart SDE command-line utility that streamlines L1X smart contract development. You can install it using the command:

      cargo install --locked --git https://github.com/L1X-Foundation-VM/l1x-cargo-sde-tools
    • To upgrade the l1x sde binary, use this command:

      cargo install --locked --force --git https://github.com/L1X-Foundation-VM/l1x-cargo-sde-tools
    • The l1x-forge tool is installed to $CARGO_HOME/bin. Make sure to update your system's PATH environment settings:

      PATH=$CARGO_HOME/bin:$PATH

Step 1: Setting Up Your Environment

  • 1.1. Create an empty folder for this demonstration.

    mkdir -p $HOME/l1x-home/l1x-sde-demo
  • 1.2. Change your current directory to the newly created folder.

    cd $HOME/l1x-home/l1x-sde-demo

Step 2: Checking the L1X Tool

  • 2.1. Ensure that the l1x-forge tool is accessible from your command line. And run the following command to see usage instructions for the tool:

l1x-forge --help

Usage: l1x-forge <COMMAND>

Commands:
  new   Create a new project workspace from a template.
  help  Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help
  • 2.2. Now, let's take a look at the official supported templates available. Run the following command:

l1x-forge new --name demo01-ft --template hello

Supported Templates ...
l1x-cross-chain-swap :: https://github.com/L1X-Foundation-VM/l1x-templ-cross-chain-swap.git
l1x-nft :: https://github.com/L1X-Foundation-VM/l1x-templ-nft.git
l1x-ft :: https://github.com/L1X-Foundation-VM/l1x-templ-ft.git
Template 'hello' not found:

Step 3: Creating Your Smart Contract Workspace

  • 3.1. Use the l1x-forge command to create a new project workspace. Here, we'll name it "demo01_ft" and use the template "l1x-ft":

    l1x-forge new --name demo01_ft --template l1x-ft
  • 3.2. After executing the command, you'll see a message confirming the creation of the contract "demo01_ft":

    Created contract demo01_ft
  • 3.3 Reference workspace populated from the template:

     	$ exa -T -L 1 ./demo01_ft
     	./demo01_ft
     	├── Cargo.lock
     	├── Cargo.toml
     	├── devbox.json
     	├── devbox.lock
     	├── devnet-services-dc.yml
     	├── l1x-conf
     	├── l1x-contracts
     	├── process-compose.yaml
     	├── README.md
     	├── rust-toolchain.toml
     	└── rustfmt.toml

Step 4: Understanding Configuration Files and Default Settings

In this section, we'll provide a quick and simple overview of the configuration files and their default values. These files are crucial for setting up your workspace effectively.

  • 4.1 devbox.json: The devbox.json file contains important configuration settings for your workspace and workflow script commands. Here are some key properties:

    Configuration
    Default
    Description

    L1X_CFG_CHAIN_TYPE

    beta_mainnet

    Specifies the chain type for deploying and working with the workspace contract. You can choose between beta_mainnet or local_devnet.

    L1X_CFG_TOOLS

    kevincoutinho007/l1x-toolkit:0.1

    Indicates the version of the Docker toolkit tested with the template. It's recommended to use the same version for this demonstration.

    L1X_CFG_ARTIFACTS

    ./l1x-artifacts

    Points to the directory where your L1X artifacts are stored.

    L1X_CFG_CONTRACT

    l1x_ft

    Specifies the name of the contract you'll be working with.

    L1X_CFG_DC_FILE

    ./devnet-services-dc.yml

    Refers to the location of the docker-compose configuration file for devnet services.

    L1X_CFG_CASSANDRA1_DATA

    ./l1x-conf/cassandra1_data

    Defines the directory for Cassandra 1 data.

    L1X_CFG_CASSANDRA2_DATA

    ./l1x-conf/cassandra2_data

    Specifies the directory for Cassandra 2 data.

    L1X_CFG_CASSANDRA_HOST

    127.0.0.1

    Specifies the Cassandra 1 Host Address.

    L1X_CFG_CASSANDRA_PORT

    9042

    Defines the Cassandra 1 Port ID.

  • 4.2 l1x-conf/l1x_chain_config.yaml: Inside the l1x-conf/l1x_chain_config.yaml file, you'll find L1X chain-specific properties, including JSON RPC endpoints. By default, the template is set to work with the Beta Mainnet using the setting "L1X_CFG_CHAIN_TYPE": "beta_mainnet". If you want to switch to a local development network, simply update this setting to "L1X_CFG_CHAIN_TYPE": "local_devnet".

These configuration files and default values are vital for configuring your workspace to match your specific requirements easily.

Step 5: Getting Started with the Devbox Shell

  • 5.1 Activating the Devbox Shell: To begin, you'll need to activate the Devbox shell. During the initial activation, Devbox will automatically install all the necessary packages for your workspace. Here's how to do it:

  • Choose the Chain Type: Begin by selecting the "L1X_CFG_CHAIN_TYPE": "local_devnet" option. Then, open a new terminal and activate the devbox shell:

  • Open your terminal and enter the following command:

devbox shell
  • 5.2 Package Installation: The system will ensure that all the required packages are installed. Here is a list of the packages that will be installed:

    Ensuring packages are installed.
    
    Installing package: cassandra_4@4.1.2.
    
    [1/1] cassandra_4@4.1.2
    [1/1] cassandra_4@4.1.2: Success
    Starting a Devbox shell...
  • 5.3 Sanity Testing: To make sure that the template and default configurations work correctly on your system, you can perform the following sanity tests:

    • To check the latest block height from the live Beta Mainnet, use this command:

    devbox run 08_check_chain_stat

Next:

Link to the Video
https://doc.rust-lang.org/cargo/getting-started/installation.html
https://www.jetpack.io/devbox/docs/quickstart/
https://docs.docker.com/engine/install/
https://docs.docker.com/compose/install/
Let's Deploy your First Contract