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
  • Note
  • Prerequisites
  • Developer playground
  1. Build with Developer Playground

Developer Playground Resource

Previous4 - Balancer-v2NextAccount

Last updated 1 year ago

Note

Binaries were tested on latest version of Ubuntu and Apple Silicon . You may face few hiccups. We will ship docker images to make it compatible with cross operating systems. For linux system please use binaries stats with linux-lix and change commands accordingly.

Prerequisites

  • Setup devbox with required templates

  • Clone the repository

  • Repository contains pre-built contracts with the source code

  • Execute following commands to build all contracts. devbox shell

    devbox run compile_all

  • This compiles contracts under l1x-contracts folder and produced compiled version with .o extension to l1x-artifacts/ folder

Developer playground

  • Clone the repository

  • Repository ships with 3 binaries to run a chain locally and to execute contracts

    • l1x_cli :- CLI to interact with the chain

    • l1x_server :- developer node binary

Running a local node

  • Please note that this will run an L1X node locally in a developer mode and you will see heaps of info on terminal.

  • Make sure you have setup Cassandra locally

  • Export following environment variables

    export REPLICATION_ENABLED=false
    export IS_LOCAL=true
    export NODE_PRIVKEY=6913aeae91daf21a8381b1af75272fe6fae8ec4a21110674815c8f0691e32758
    
  • Initialize the genesis configuration ./l1x_server init

  • Run the local node

    RUST_LOG=info ./l1x_server start
  • This spins up a local node in developer mode

Interact with local node using CLI

  • Open a separate terminal and source environment variable(s)

    export PRIV_KEY=6d657bbe6f7604fb53bc22e0b5285d3e2ad17f64441b2dc19b648933850f9b46

  • Execute ./l1x_cli to view options

  • To perform native token transfer execute ./l1x_cli --private-key $PRIV_KEY submit-txn --payload-file-path txn-payload/native_token_transfer.json You will see the following response

"SubmitTransactionResponse"{ "hash":"7696d4b9005b0ffe1a811751a1d8d18f0addcf2f95d3985caf5c51efb0793a54", "contract_address":"None" }

Exploring playground

  • Under txn-payload there are several sections

    • compiled-contracts

      • Place compiled contracts from example repository to corresponding folders or else you can make your own structure.

  • Smart contract deployment

    • For this example we are placing a compiled contract l1x-contract.o under txn-payload\compiled-contracts\l1x-contract

    • Find the file smart_contract_deployment.json and you will see a structure similar to this Change the file attribute to corresponding path

      {
        "smart_contract_deployment": [
          "PRIVATE",
          "L1XVM",
          {
            "file": "txn-payload/compiled_contracts/l1x_contract/l1x_contract.o"
          },
          0,
          {
            "text": "00000000000000000000000000000000"
          }
        ]
      }
    • Execute the following command to do a smart contract deployment

      ./l1x_cli --private-key $PRIV_KEY submit-txn --payload-file-path txn-payload/smart_contract_deployment.json

    • Now we have deployed our first contract , now we can initialize a contract and invoke its functions

    • To initialize the contract execute Open the file smart_contract_init.json Add the contract address from deployment call to hex field.

      {
        "smart_contract_init": [
          { "hex": "f92286d5f2da5fb627f0b4506d40b0ad98f377c0" },
          { "text": "{}" }
        ]
      }

      and execute the command

      ./l1x_cli --private-key $PRIV_KEY submit-txn --payload-file-path txn-payload/smart_contract_init.json
    • Smart contract function call Open the file smart_contract_function_call.json Replace contract instance address from init call response

      "contract_instance_address": {
        "hex": "beedf108ae904c2adc6700663cf1c850e096094c"
      },

      Since you already know available functions in the contract you have compiled from examples repository, you can specify function name on the text field under function and arguments

      {
        "smart_contract_function_call": {
          "contract_instance_address": {
            "hex": "beedf108ae904c2adc6700663cf1c850e096094c"
          },
          "function": {
            "text": "save_event_data"
          },
          "arguments": {
            "text": "{\"global_tx_id\": \"10EC8B28F0F3881BC108B367A9FEED1AA625FBFCBF56F9BC8FA36FDDAAFD5F00\", \"event_type\": \"SwapInitiated\", \"source_id\": \"0\", \"event_data\": \"eyJhZGRyZXNzIjoiMHg3Y2IxM2MyMGIxYzRhZDA4ZjYxNDVjNDJhODZkOWRjMDE5YjBhMjZlIiwidG9waWNzIjpbIjB4MjAzNGM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DAwMDAwMDAwMDAwMDAwMDAwMDAwMDg2NTc0Njg2NTcyNjU3NTZkMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwIiwiYmxvY2tIYXNoIjoiMHhhMGEyNmYzNGJiOGFlMTAxYzhmY2MzNTQ2YTcyMzNkZGFkYjJiZGI2MTljZDUxMTlmNzk3OWI2MWQ5YmUzMTM3IiwiYmxvY2tOdW1iZXIiOiIweDY3ZTgxMmQiLCJ0cmFuc2FjdGlvbkhhc2giOiIweGY3NDEzYWU5MmNlZTBiODQ1ZDFlNTJiODlhYTRkMTRkNTczYWI0NThjMGM4ZjUyYTIzZGE4NTY5OGYzODQwNDIiLCJ0cmFuc2FjdGlvbkluZGV4IjoiMHhhIiwibG9nSW5kZXgiOiIweDI0IiwicmVtb3ZlZCI6ZmFsc2V9\"}"
          }
        }
      }
  • You can explore available json configuration files for each contracts .

  • You can change the compiled file paths accordingly

EVM ERC 20 token deployment demo video

Please refer to the README for complete list of CLI commands (Share the link here)

https://github.com/L1X-Foundation-Consensus/l1x-examples
https://github.com/L1X-Foundation-Consensus/L1X-DEV-PLAYGROUND
https://github.com/L1X-Foundation-Consensus/L1X-DEV-PLAYGROUND#readme
85MB
evm playground.mov