### Setup and Run Next.js Frontend Source: https://docs.genlayer.com/developers/intelligent-contracts/tooling-setup Instructions for setting up and running a Next.js frontend project that integrates with GenLayerJS. This involves navigating to the frontend directory, installing dependencies, and starting the development server. ```bash cd frontend npm install npm run dev ``` -------------------------------- ### Download and Install GenLayer Node Software Source: https://docs.genlayer.com/validators/setup-guide Commands to fetch the latest node version, download the compressed binary, extract it, and execute the GenVM setup script for environment preparation. ```bash curl -s "https://storage.googleapis.com/storage/v1/b/gh-af/o?prefix=genlayer-node/bin/amd64" | grep -o '"name": *"[^"]*"' | sed -n 's/.*\/\(v[^/]*\)\/.*/\1/p' | sort -ru | grep -v "rc" | head -n 5 export version=v0.5.7 wget https://storage.googleapis.com/gh-af/genlayer-node/bin/amd64/${version}/genlayer-node-linux-amd64-${version}.tar.gz mkdir -p ${version} tar -xzvf genlayer-node-linux-amd64-${version}.tar.gz -C ./${version} cd ./${version} python3 ./third_party/genvm/bin/setup.py ``` -------------------------------- ### Install GenLayer CLI Source: https://docs.genlayer.com/validators/setup-guide Command to install the GenLayer CLI tool globally using npm. This is a prerequisite for manual validator setup and wallet management. ```shell npm install -g genlayer ``` -------------------------------- ### Start GLSim Simulator Source: https://docs.genlayer.com/developers/intelligent-contracts/tooling-setup Launches the GLSim lightweight simulator for GenLayer. This simulator starts quickly and does not require Docker. It's suitable for fast development cycles. ```bash # Start the simulator glsim --port 4000 --validators 5 # Your frontend connects to http://localhost:4000/api # Integration tests run against it gltest tests/integration/ -v -s ``` -------------------------------- ### Initialize and Start GenLayer Studio (Local) Source: https://docs.genlayer.com/developers/intelligent-contracts/tooling-setup Sets up and runs GenLayer Studio locally using Docker. This provides full GenVM execution and debugging capabilities. The `genlayer init` command initializes the project, and `genlayer up` starts the environment. ```bash npm install -g genlayer genlayer init genlayer up # Integration tests run against the local network gltest tests/integration/ -v -s --network localnet ``` -------------------------------- ### Install and Configure GenLayer AI Wizard Source: https://docs.genlayer.com/validators/setup-guide Commands to install the GenLayer plugin for Claude Code and initiate the interactive validator setup wizard. This method automates prerequisite checks and configuration generation. ```shell claude /plugin marketplace add genlayerlabs/skills claude /plugin install genlayernode@genlayerlabs claude /genlayernode install ``` -------------------------------- ### Start and Verify GenLayer Node Service Source: https://docs.genlayer.com/validators/genvm-configuration Provides commands to start the GenLayer node service using systemctl and to verify its operation by checking journal logs for 'greybox' entries. This helps confirm that the greybox LLM module is active and processing transactions. ```shell sudo systemctl start genlayer-node sudo journalctl -u genlayer-node --no-hostname | grep "greybox" # Expected output examples: greybox: using text chain count: 5 greybox: success provider: openrouter model: deepseek/deepseek-v3.2 is_primary: true ``` -------------------------------- ### Direct Mode Contract Test Example Source: https://docs.genlayer.com/developers/intelligent-contracts/tooling-setup An example of a direct mode test using `pytest` fixtures. It demonstrates deploying a contract, setting the transaction sender, calling write methods, and asserting the results of view methods. ```python import json def test_create_and_read(direct_vm, direct_deploy, direct_alice): contract = direct_deploy("contracts/my_contract.py") # Set the transaction sender direct_vm.sender = direct_alice # Call write methods directly contract.set_data("hello") # Call view methods result = contract.get_data(direct_alice) assert result == "hello" ``` -------------------------------- ### Interact with GenLayer Contracts using GenLayerJS Source: https://docs.genlayer.com/developers/intelligent-contracts/tooling-setup Example code demonstrating how to use the GenLayerJS client to interact with smart contracts. It shows how to create a client instance, read data from a contract, and write data to a contract, including waiting for transaction confirmation. ```javascript import { createClient } from 'genlayer-js'; const client = createClient({ endpoint: 'http://localhost:4000/api' }); // Read from a contract const value = await client.readContract({ address: contractAddress, functionName: "get_data", args: [], }); // Write to a contract const txHash = await client.writeContract({ address: contractAddress, functionName: "set_data", args: [newValue], }); const receipt = await client.waitForTransactionReceipt({ hash: txHash, status: "FINALIZED", }); ``` -------------------------------- ### Initialize and Start Localnet with GenLayer CLI Source: https://docs.genlayer.com/developers/intelligent-contracts/deploying/network-configuration Commands to set up and run a local GenLayer network for development and testing. This requires the GenLayer Studio to be installed locally. ```bash # Initialize local network genlayer init # Start the local network genlayer up ``` -------------------------------- ### Python Integration Test Example with GenLayer SDK Source: https://docs.genlayer.com/developers/intelligent-contracts/tooling-setup Demonstrates a full contract interaction flow using the `genlayer-test` Python SDK. It shows how to deploy a contract, call write methods (which return transaction receipts), and call read methods (which return values directly). ```python from gltest import get_contract_factory from gltest.assertions import tx_execution_succeeded def test_full_flow(): factory = get_contract_factory("MyContract") contract = factory.deploy(args=[]) # Write methods return transaction receipts tx_receipt = contract.set_data(args=["hello"]).transact() assert tx_execution_succeeded(tx_receipt) # Read methods return values directly result = contract.get_data(args=[contract.address]).call() assert result == "hello" ``` -------------------------------- ### Install and Initialize GenLayer CLI Source: https://docs.genlayer.com/developers/intelligent-contracts/tools/genlayer-cli Commands to install the GenLayer CLI globally via npm and initialize the local development environment. ```shell npm install -g genlayer genlayer init ``` -------------------------------- ### Install Dependencies and Run Development Server Source: https://docs.genlayer.com/developers/decentralized-applications/project-boilerplate Commands to install necessary Node.js dependencies and launch the Vite development server for the Vue.js frontend. ```shell npm install npm run dev ``` -------------------------------- ### Start Node Services Source: https://docs.genlayer.com/validators/setup-guide Launches the GenLayer node services in detached mode using Docker Compose with the node profile enabled. ```bash source .env && docker compose --profile node up -d ``` -------------------------------- ### Manage Validator Staking and Identity Source: https://docs.genlayer.com/validators/setup-guide CLI commands for initializing a validator wallet, verifying status, and managing staking operations like deposits, exits, and identity updates. ```bash genlayer staking wizard genlayer staking validator-info --validator 0xYourValidatorWallet... genlayer staking validator-deposit --amount 1000gen genlayer staking active-validators genlayer staking validator-exit --shares 100 genlayer staking validator-claim genlayer staking set-identity --validator 0x... --moniker "New Name" ``` -------------------------------- ### Configure GenLayer Node via config.yaml Source: https://docs.genlayer.com/validators/setup-guide Example configuration structure for the GenLayer node, defining rollup RPC endpoints, consensus contract addresses, and data directory paths. ```yaml rollup: genlayerchainrpcurl: "TODO: Set your GenLayer Chain ZKSync HTTP RPC URL here" genlayerchainwebsocketurl: "TODO: Set your GenLayer Chain ZKSync WebSocket RPC URL here" consensus: consensusaddress: "0xe66B434bc83805f380509642429eC8e43AE9874a" genesis: 17326 datadir: "./data/node" ``` -------------------------------- ### Example Custom LLM Provider Plugin Implementation (Python) Source: https://docs.genlayer.com/developers/intelligent-contracts/tools/genlayer-studio/advanced-features/custom-plugins This Python example demonstrates how to implement a custom LLM provider plugin by inheriting from the `Plugin` protocol. It includes placeholder logic for initialization, API calls using `aiohttp`, and availability checks. This serves as a practical template for developers. ```python import aiohttp class MyCustomPlugin: def __init__(self, plugin_config: dict): self.api_key = plugin_config.get('api_key') self.base_url = plugin_config.get('base_url', 'https://api.customllm.com') # Add any other necessary configuration parameters async def call( self, node_config: dict, prompt: str, regex: Optional[str], return_streaming_channel: Optional[asyncio.Queue], ) -> str: # Implement the API call to your custom LLM provider # This is a placeholder implementation async with aiohttp.ClientSession() as session: async with session.post( f"{self.base_url}/generate", json={"prompt": prompt, "config": node_config}, headers={"Authorization": f"Bearer {self.api_key}"} ) as response: if response.status == 200: result = await response.json() return result['generated_text'] else: raise Exception(f"API call failed with status {response.status}") def is_available(self) -> bool: # Check if the plugin is properly configured and available return bool(self.api_key) and bool(self.base_url) def is_model_available(self, model: str) -> bool: # Check if the specified model is available for this provider # This is a placeholder implementation available_models = ['custom-gpt-3', 'custom-gpt-4'] return model in available_models ``` -------------------------------- ### Install Python Dependencies for GenLayer Source: https://docs.genlayer.com/developers/intelligent-contracts/tooling-setup Installs the necessary Python dependencies for GenLayer contract development, linting, and testing. This includes the `genlayer-test` framework and the `genvm-linter`. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install GenLayer Test SDK Source: https://docs.genlayer.com/api-references/genlayer-test Command to install the GenLayer testing library via pip. ```bash pip install genlayer-test ``` -------------------------------- ### Usage Examples Source: https://docs.genlayer.com/api-references/genlayer-node Examples demonstrating how to use the GenLayer API with cURL for various operations like testing connectivity, executing contract calls, retrieving contract schemas, debug trie information, and transaction receipts. ```APIDOC ## Usage Examples ### cURL ```bash # Test connectivity curl -X POST http://localhost:9151 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "gen_dbg_ping", "params": [], "id": 1 }' # Execute a contract call curl -X POST http://localhost:9151 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "gen_call", "params": [{ "from": "0x742d35Cc6634C0532925a3b8D4C9db96c4b4d8b6", "to": "0x742d35Cc6634C0532925a3b8D4C9db96c4b4d8b6", "data": "0x70a08231000000000000000000000000742d35cc6634c0532925a3b8d4c9db96c4b4d8b6", "type": "read", "transaction_hash_variant": "latest-nonfinal" }], "id": 1 }' # Get contract schema curl -X POST http://localhost:9151 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "gen_getContractSchema", "params": [{ "code": "IyB7ICJEZXBlbmRzIjogInB5LWdlbmxheWVyOnRlc3QiIH0KCmZyb20gZ2VubGF5ZXIgaW1wb3J0ICoKCgojIGNvbnRyYWN0IGNsYXNzCmNsYXNzIFN0b3JhZ2UoZ2wuQ29udHJhY3QpOgogICAgc3RvcmFnZTogc3RyCgogICAgIyBjb25zdHJ1Y3RvcgogICAgZGVmIF9faW5pdF9fKHNlbGYsIGluaXRpYWxfc3RvcmFnZTogc3RyKToKICAgICAgICBzZWxmLnN0b3JhZ2UgPSBpbml0aWFsX3N0b3JhZ2UKCiAgICAjIHJlYWQgbWV0aG9kcyBtdXN0IGJlIGFubm90YXRlZCB3aXRoIHZpZXcKICAgIEBnbC5wdWJsaWMudmlldwogICAgZGVmIGdldF9zdG9yYWdlKHNlbGYpIC0+IHN0cjoKICAgICAgICByZXR1cm4gc2VsZi5zdG9yYWdlCgogICAgIyB3cml0ZSBtZXRob2QKICAgIEBnbC5wdWJsaWMud3JpdGUKICAgIGRlZiB1cGRhdGVfc3RvcmFnZShzZWxmLCBuZXdfc3RvcmFnZTogc3RyKSAtPiBOb25lOgogICAgICAgIHNlbGYuc3RvcmFnZSA9IG5ld19zdG9yYWdlCg==" }], "id": 1 }' # Get debug trie information curl -X POST http://localhost:9151 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "gen_dbg_trie", "params": [{ "txID": "0x742d35Cc6634C0532925a3b8D4C9db96c4b4d8b6742d35Cc6634C0532925a3b8", "round": 0 }], "id": 1 }' # Get transaction receipt curl -X POST http://localhost:9151 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "gen_getTransactionReceipt", "params": [{ "txId": "0x635060dd514082096d18c8eb64682cc6a944f9ce1ae6982febf7a71e9f656f49" }], "id": 1 }' ``` ``` -------------------------------- ### Complete Contract Interaction Example with Genlayer SDK Source: https://docs.genlayer.com/api-references/genlayer-js A comprehensive example demonstrating how to interact with a deployed smart contract using the Genlayer SDK. It covers client initialization (with direct signing or MetaMask), reading contract data, and writing data to the contract, followed by waiting for transaction confirmation. ```javascript import { createClient, createAccount } from 'genlayer-js'; import { localnet } from 'genlayer-js/chains'; import { TransactionStatus } from 'genlayer-js/types'; async function interactWithContract() { // Option 1: Direct signing with private key const account = createAccount(); const client = createClient({ chain: localnet, account: account, // SDK handles signing }); // Option 2: MetaMask signing (just provide address) // const client = createClient({ // chain: localnet, // account: '0x1234...', // MetaMask handles signing // }); await client.initializeConsensusSmartContract(); const contractAddress = '0x...'; // Your deployed contract address // Read current bets const bets = await client.readContract({ address: contractAddress, functionName: 'get_bets', args: [], }); console.log('Current bets:', bets); // Create a new bet const txHash = await client.writeContract({ address: contractAddress, functionName: 'create_bet', args: ['2024-06-20', 'Spain', 'Italy', 1], value: 0n, }); // Wait for confirmation const receipt = await client.waitForTransactionReceipt({ hash: txHash, status: TransactionStatus.ACCEPTED, }); console.log('Bet created successfully:', receipt); } ``` -------------------------------- ### Troubleshoot WebDriver Container Source: https://docs.genlayer.com/api-references/genlayer-node Commands to verify the status of the WebDriver container and start it if it is not currently running. ```bash docker ps | grep genlayer-node-webdriver task docker:webdriver:docker-compose:up:detach ``` -------------------------------- ### Start GenLayer Environment Source: https://docs.genlayer.com/references/genlayer-cli Launches the GenLayer environment and Studio, initializing a fresh database and accounts. Options include resetting validators, specifying the number of validators, headless mode, and database reset. ```bash genlayer up genlayer up --reset-validators --numValidators 8 --headless --reset-db ``` -------------------------------- ### GenLayer Network Switching Workflow Examples Source: https://docs.genlayer.com/developers/intelligent-contracts/deploying/network-configuration Illustrative commands demonstrating the workflow for switching between different GenLayer networks (Localnet, Studionet, TestnetBradbury) for development, testing, and pre-production stages. ```bash # Development workflow genlayer network localnet genlayer deploy --contract contracts/my_contract.py # Testing workflow genlayer network studionet genlayer deploy --contract contracts/my_contract.py # Pre-production workflow genlayer network testnet-bradbury genlayer deploy --contract contracts/my_contract.py ``` -------------------------------- ### Configure Monitoring Environment Variables Source: https://docs.genlayer.com/validators/setup-guide Defines the required environment variables for connecting a GenLayer node to centralized Prometheus and Loki monitoring endpoints. ```bash # Central monitoring server endpoints for GenLayer Foundation CENTRAL_MONITORING_URL=https://prometheus-prod-66-prod-us-east-3.grafana.net/api/prom/push CENTRAL_LOKI_URL=https://logs-prod-042.grafana.net/loki/api/v1/push # Authentication for central monitoring CENTRAL_MONITORING_USERNAME=your-metrics-username CENTRAL_MONITORING_PASSWORD=your-metrics-password CENTRAL_LOKI_USERNAME=your-logs-username CENTRAL_LOKI_PASSWORD=your-logs-password # Node identification NODE_ID=validator-001 VALIDATOR_NAME=MyValidator ``` -------------------------------- ### Staking Setup (JavaScript) Source: https://docs.genlayer.com/api-references/genlayer-js Sets up the GenLayer client for staking operations on the testnet. This involves importing the testnet chain configuration and creating an account for the client. ```javascript import { testnetBradbury } from 'genlayer-js/chains'; import { createClient, createAccount } from "genlayer-js"; const account = createAccount(); const client = createClient({ chain: testnetBradbury, account, }); ``` -------------------------------- ### Add GenLayer MCP Server to Claude Code Source: https://docs.genlayer.com/developers/intelligent-contracts/tooling-setup Installs and configures the GenLayer MCP Server for Claude Code, enabling contract generation and GenLayer-specific guidance within the IDE. ```bash # Add to Claude Code claude mcp add genlayer npx -- -y genlayer-mcp ``` -------------------------------- ### Verify Node Configuration Source: https://docs.genlayer.com/validators/setup-guide Uses the GenLayer node doctor command to validate the current environment and configuration files. It requires a populated .env file and mounts the configuration path into the container. ```bash source .env && docker run --rm --env-file ./.env \ -v ${NODE_CONFIG_PATH:-./configs/node/config.yaml}:/app/configs/node/config.yaml \ yeagerai/genlayer-node:${NODE_VERSION:-v0.4.0} \ ./bin/genlayernode doctor ``` -------------------------------- ### Clone GenLayer Project Boilerplate Source: https://docs.genlayer.com/developers/intelligent-contracts/tooling-setup Clones the official GenLayer Project Boilerplate repository, which serves as a starting point for developing Intelligent Contracts. This includes contract templates, testing infrastructure, and a frontend scaffold. ```bash git clone https://github.com/genlayerlabs/genlayer-project-boilerplate.git cd genlayer-project-boilerplate ``` -------------------------------- ### Manage Contract Factory and Deployment Source: https://docs.genlayer.com/api-references/genlayer-test Shows how to retrieve a contract factory, deploy a new instance of a contract, and build a reference to an existing contract address. ```python from gltest import get_contract_factory, create_account # Get factory factory = get_contract_factory('Storage') # Deploy new contract custom_account = create_account() contract = factory.deploy(args=["initial_value"], account=custom_account) # Build from existing address existing_contract = factory.build_contract(contract_address="0xabcd...z") ``` -------------------------------- ### GenLayer Storage Contract: Python Source: https://docs.genlayer.com/developers/intelligent-contracts/examples/storage A Python smart contract for GenLayer demonstrating basic data storage and retrieval. It includes methods to initialize, get, and update a string value. Dependencies include the 'py-genlayer' library. ```python # { "Depends": "py-genlayer:1jb45aa8ynh2a9c9xn3b7qqh8sm5q93hwfp7jqmwsfhh8jpz09h6" } from genlayer import * # contract class class Storage(gl.Contract): storage: str # constructor def __init__(self, initial_storage: str): self.storage = initial_storage # read methods must be annotated with view @gl.public.view def get_storage(self) -> str: return self.storage # write method @gl.public.write def update_storage(self, new_storage: str) -> None: self.storage = new_storage ``` -------------------------------- ### Define a GenLayer Intelligent Contract Source: https://docs.genlayer.com/developers/intelligent-contracts/tooling-setup A Python example demonstrating how to define an Intelligent Contract using the `genlayer` library. It includes a `TreeMap` for data storage and public view/write methods for interacting with the contract's state. ```python from genlayer import * class MyContract(gl.Contract): data: TreeMap[Address, str] def __init__(self): self.data = TreeMap() @gl.public.view def get_data(self, addr: Address) -> str: return self.data.get(addr, "") @gl.public.write def set_data(self, value: str): self.data[gl.message.sender_address] = value ``` -------------------------------- ### Execute GenLayer CLI Commands Source: https://docs.genlayer.com/developers/intelligent-contracts/tools/genlayer-cli General syntax for executing CLI commands with optional parameters and a specific example of initializing the studio with custom validator and branch settings. ```shell genlayer [options] genlayer init --numValidators 10 --branch develop ``` -------------------------------- ### GenLayer Versioning and Imports Source: https://docs.genlayer.com/developers/intelligent-contracts/your-first-contract The mandatory setup steps for any GenLayer contract file, including the versioning magic comment and importing the GenLayer standard library. ```python # { "Depends": "py-genlayer:1jb45aa8ynh2a9c9xn3b7qqh8sm5q93hwfp7jqmwsfhh8jpz09h6" } from genlayer import * ``` -------------------------------- ### Deploy Smart Contract with GenLayer SDK Source: https://docs.genlayer.com/references/genlayer-js Demonstrates how to initialize a client, read a contract file, and deploy it to the GenLayer network. It includes handling transaction receipts to confirm successful deployment. ```javascript import { createClient, createAccount } from 'genlayer-js'; import { localnet } from 'genlayer-js/chains'; import { readFileSync } from 'fs'; import { TransactionStatus } from 'genlayer-js/types'; async function deployContract() { const account = createAccount(); const client = createClient({ chain: localnet, account: account, }); await client.initializeConsensusSmartContract(); const contractCode = readFileSync('./contracts/football_bets.py', 'utf-8'); const hash = await client.deployContract({ code: contractCode, args: [], leaderOnly: false, }); const receipt = await client.waitForTransactionReceipt({ hash, status: TransactionStatus.ACCEPTED, retries: 50, interval: 5000, }); return receipt.data?.contract_address; } ``` -------------------------------- ### Initialize GenLayer Environment Source: https://docs.genlayer.com/api-references/genlayer-cli Prepares the local environment for GenLayer Studio. Supports custom versioning, validator counts, and database resets. ```bash genlayer init --localnet-version v0.10.2 genlayer init --numValidators 10 --headless --reset-db --localnet-version v0.10.2 ``` -------------------------------- ### Update LLM Module on Running GenLayer Node Source: https://docs.genlayer.com/validators/genvm-configuration Explains how to update the LLM module's Lua script and configuration on a running GenLayer node without requiring a full service restart. This is achieved by sending POST requests to stop and then start the LLM module via its manager port. ```shell # Find the GenVM manager port (check your config or active ports) PORT=3999 # Stop the LLM module curl -X POST "http://127.0.0.1:${PORT}/module/stop" \ -H 'Content-Type: application/json' \ -d '{"module_type": "Llm"}' # Start the LLM module (reloads Lua script and config) curl -X POST "http://127.0.0.1:${PORT}/module/start" \ -H 'Content-Type: application/json' \ -d '{"module_type": "Llm", "config": null}' ``` -------------------------------- ### Basic Intelligent Contract Structure in Python Source: https://docs.genlayer.com/build-with-genlayer/intelligent-contracts Demonstrates the fundamental structure of an Intelligent Contract using the GenVM SDK in Python. It includes dependency declaration, contract definition, state variables, and different types of methods (view, write, payable). ```python # { "Depends": "py-genlayer:1jb45aa8ynh2a9c9xn3b7qqh8sm5q93hwfp7jqmwsfhh8jpz09h6" } from genlayer import * class MyContract(gl.Contract): # State variables with type annotations variable: str def __init__(self): self.variable = "initial value" @gl.public.view def read_method(self) -> str: return self.variable @gl.public.write def write_method(self, new_value: str): self.variable = new_value ``` -------------------------------- ### Install GenLayerJS SDK Source: https://docs.genlayer.com/developers/decentralized-applications/genlayer-js The command to install the GenLayerJS SDK package via the npm package manager. ```bash npm install genlayer-js ``` -------------------------------- ### Manage Local Accounts and Keystores Source: https://docs.genlayer.com/references/genlayer-cli Tools for creating, importing, exporting, and securing accounts using encrypted keystores. Includes functionality for sending tokens and managing active account sessions. ```bash genlayer account create --name owner genlayer account unlock --account owner genlayer account send --to 0x123... --amount 100gen ``` -------------------------------- ### Start Docker Compose for Monitoring Source: https://docs.genlayer.com/validators/monitoring Command to start the monitoring stack using Docker Compose. This command brings up the necessary services, including the GenLayer node and Alloy. ```bash docker compose --profile monitoring up -d ``` -------------------------------- ### GenLayer Write Call Example Source: https://docs.genlayer.com/api-references/genlayer-node Illustrates a 'write' call to a GenLayer contract, which modifies the contract state. This example includes parameters for the sender ('from'), recipient ('to'), transaction data ('data'), type ('write'), gas limit, and value. ```json { "jsonrpc": "2.0", "method": "gen_call", "params": [ { "from": "0x742d35Cc6634C0532925a3b8D4C9db96c4b4d8b6", "to": "0x742d35Cc6634C0532925a3b8D4C9db96c4b4d8b6", "data": "0xa9059cbb000000000000000000000000742d35cc6634c0532925a3b8d4c9db96c4b4d8b6", "type": "write", "gas": "0x5208", "value":"0x0" } ], "id": 1 } ``` -------------------------------- ### Join Staking in Epoch 0 Source: https://docs.genlayer.com/developers/staking-guide Demonstrates how to join as a delegator during the bootstrapping phase. Note that there is no minimum stake requirement in Epoch 0 and shares are issued at a 1:1 ratio. ```Solidity // In epoch 0, any amount is accepted (no 42 GEN minimum) genStaking.delegatorJoin{value: 10 ether}(validatorWallet); // Epoch 0: 1,000 GEN deposit = 1,000 shares (1:1 ratio) genStaking.delegatorJoin{value: 1000 ether}(validatorWallet); ``` -------------------------------- ### Send Value Transaction Example (JSON) Source: https://docs.genlayer.com/understand-genlayer-protocol/core-concepts/transactions/types-of-transactions This JSON object illustrates a transaction for sending the native GEN token between accounts on GenLayer. It includes sender and receiver addresses, transaction value, and status information. ```json { "consensus_data": null, "created_at": "2024-10-02T21:21:04.192995+00:00", "data": {}, "from_address": "0x0Bd6441CB92a64fA667254BCa1e102468fffB3f3", "gaslimit": 0, "hash": "0x6357ec1e86f003b20964ef3b2e9e072c7c9521f92989b08e04459b871b69de89", "leader_only": false, "nonce": 2, "r": null, "s": null, "status": "FINALIZED", "to_address": "0xf739FDe22E0C0CB6DFD8f3F8D170bFC07329489E", "type": 0, "v": null, "value": 200 } ``` -------------------------------- ### Initialize and Configure GenLayer Project Source: https://docs.genlayer.com/developers/decentralized-applications/project-boilerplate Commands to clone the boilerplate repository and initialize environment variables for both the project root and the frontend application. ```shell git clone https://github.com/genlayerlabs/genlayer-project-boilerplate cd genlayer-project-boilerplate cp .env.example .env ``` ```shell cd app cp .env.example .env ``` -------------------------------- ### Deploy Contracts (Python) Source: https://docs.genlayer.com/developers/intelligent-contracts/features/interacting-with-intelligent-contracts Provides examples for deploying new contracts. Contracts can be deployed with or without a salt. Using a salt allows for deterministic deployment. ```python gl.deploy_contract(code=contract_code) salt: u256 = u256(1) # not zero child_address = gl.deploy_contract(code=contract_code, salt=salt) ``` -------------------------------- ### GenLayer Type Conversion Utilities Example Source: https://docs.genlayer.com/developers/intelligent-contracts/types/primitive Provides utility functions for converting between common data types in GenLayer. This snippet includes examples for converting strings to bytes and vice-versa, as well as integer to string and string to integer conversions. ```python class TypeConversionUtils(gl.Contract): def __init__(self): pass @gl.public.view def string_to_bytes(self, text: str) -> bytes: return text.encode('utf-8') @gl.public.view def bytes_to_string(self) -> str: return b"binary_data_here".decode('utf-8') @gl.public.view def int_to_string(self, value: int) -> str: return str(value) @gl.public.view def string_to_int(self, value_str: str) -> int: return int(value_str) ```