๐Ÿš€ Quick Start Guide - Get Started in 5 Minutes

Beta Release v1.0.8: dist_agent_lang is actively developed with consistent updates. This is a beta release โ€” test thoroughly before production use. Beta testing contributions appreciated!

Welcome to dist_agent_lang (DAL) - the hybrid language for decentralized smart contracts and centralized services!

This guide will get you from zero to your first DAL program in 5 minutes.


๐Ÿ“ฆ Installation (30 seconds)

cargo install dist_agent_lang

Option 2: From source

git clone https://github.com/okjason-source/dist_agent_lang.git
cd dist_agent_lang
cargo build --release
export PATH="$PWD/target/release:$PATH"

Option 3: From release binary

Download from GitHub Releases and extract the binary (dal or dal.exe) to your PATH.

Verify Installation

dal --version
# Expected: dist_agent_lang v1.0.8

๐ŸŽฏ Your First DAL Program (3 minutes)

Step 1: Create a New File

# Create your first DAL file
touch hello.dal

Step 2: Write Your Program

Copy this into hello.dal:

// hello.dal - Your first DAL program!

fn main() {
    let greeting = "Hello, dist_agent_lang!";
    log::info("hello", greeting);
    
    let result = add_numbers(10, 20);
    log::info("result", { "sum": result });
}

fn add_numbers(a: int, b: int) -> int {
    return a + b;
}

Step 3: Run It

dal run hello.dal

# Output:
# ๐Ÿš€ Running dist_agent_lang file: hello.dal
# โœ… Tokenization successful! Generated 25 tokens
# โœ… Parsing successful! Generated 2 statements
# [INFO] "hello": "Hello, dist_agent_lang!"
# [INFO] "result": {"sum": 30}
# โœ… Execution successful!

๐ŸŒ Your First Service (2 minutes)

Create a Service

Create greeting.dal:

// greeting.dal - A simple service example

@trust("hybrid")
service GreetingService {
    message: string = "Hello";
    
    fn initialize(msg: string) {
        self.message = msg;
    }
    
    fn greet(name: string) -> string {
        return self.message + ", " + name + "!";
    }
    
    fn get_message() -> string {
        return self.message;
    }
}

// Use the service
fn main() {
    let service = GreetingService::new();
    service.initialize("Welcome");
    
    let greeting = service.greet("Alice");
    log::info("greeting", greeting);
    // Output: "Welcome, Alice!"
}

Run the Service

dal run greeting.dal

๐Ÿงช Test Your Code

Run Tests

# Run all tests in current directory
dal test

# Run tests for a specific file
dal test hello.dal

Create a Test File

Create hello.test.dal:

// hello.test.dal - Test file

fn test_add_numbers() {
    let result = add_numbers(5, 3);
    assert(result == 8, "5 + 3 should equal 8");
}

fn add_numbers(a: int, b: int) -> int {
    return a + b;
}

Run it:

dal test hello.test.dal

๐Ÿ” Code Quality Tools

Check Syntax

dal check hello.dal
# Validates syntax and type checking

Parse (Syntax Validation)

dal parse hello.dal
# Shows parse tree and validates syntax

Format Code

dal fmt hello.dal
# Formats your DAL code consistently

Lint Code

dal lint hello.dal
# Checks for common issues and best practices

๐Ÿ“š Next Steps

Congratulations! You've just:

Continue Learning

  1. Syntax Reference - Learn DAL syntax in detail
  2. Attributes Reference - Understand @trust, @secure, @chain, etc.
  3. Standard Library - Explore 22 stdlib modules
  4. CLI Reference - Complete command reference
  5. Examples - See real-world code examples

Try More Examples

# View available examples
ls examples/

# Run example programs
dal run examples/hello_world_demo.dal
dal run examples/smart_contract.dal
dal run examples/ai_agent_examples.dal

๐Ÿ†˜ Troubleshooting

Build Errors

# Clean and rebuild
cargo clean
cargo build --release

Syntax Errors

# Check syntax
dal check hello.dal

# Parse with verbose output
dal parse hello.dal

Runtime Errors

# Run with verbose logging
RUST_LOG=debug dal run hello.dal

๐Ÿ’ก Quick Tips

1. Use the REPL

dal repl
# Interactive shell for testing code snippets

2. Watch Mode

dal watch hello.dal
# Auto-runs on file save

3. Create New Projects

dal new my-project
# Creates a new project structure

dal new my-ai --type ai
# Creates an AI-focused project

4. Format Before Committing

dal fmt hello.dal
# Ensures consistent code style

๐ŸŽ“ Key Concepts (30-second overview)

Services

Services are the main building blocks in DAL:

@trust("hybrid")
@chain("ethereum")
service MyService {
    count: int = 0;
    
    fn increment() {
        self.count = self.count + 1;
    }
}

Attributes

Use attributes to control behavior:

Standard Library Namespaces

DAL provides 22 standard library modules:

// Logging
log::info("category", "message");
log::error("category", "error");

// Authentication
auth::create_user("alice", "password", "email");
auth::authenticate("alice", "password");

// Blockchain
chain::deploy(1, "Contract", []);
chain::call(1, "0x...", "function", []);

// Crypto
crypto::hash("data", "SHA256");
crypto::sign("data", "private_key", SignatureAlgorithm::ECDSA);

// And many more: oracle::, service::, database::, web::, ai::, etc.

Multi-Chain Support

@trust("hybrid")
@chain("ethereum", "polygon", "arbitrum")
service MultiChainService {
    // Automatically works across all specified chains!
}

Built-in Security

@trust("hybrid")
@secure
service SecureService {
    // Automatic:
    // - Reentrancy protection
    // - Safe math (overflow protection)
    // - Audit logging
    // - Capability checks
}

๐ŸŒŸ What Makes DAL Special?

Feature DAL Solidity Rust
Multi-Chain โœ… Native โŒ โš ๏ธ Limited
Type Safety โœ… Strong โš ๏ธ Medium โœ… Strong
Security โœ… Built-in โš ๏ธ Manual โš ๏ธ Manual
Oracle Access โœ… Native โŒ External โŒ External
AI Integration โœ… Native โŒ โš ๏ธ External
Hybrid Trust โœ… Native โŒ โŒ
Learning Curve ๐ŸŸข Moderate ๐ŸŸข Easy ๐Ÿ”ด Steep
Agent Support โœ… First-class โŒ โš ๏ธ External

๐Ÿค Get Help


๐Ÿ“ Example Projects

Check out complete examples in the examples/ directory:

cd examples/

# Core language features
dal run hello_world_demo.dal
dal run enhanced_language_features.dal

# Services and smart contracts
dal run smart_contract.dal
dal run defi_nft_rwa_contract.dal

# AI and agents
dal run ai_agent_examples.dal
dal run agent_system_demo.dal

# Multi-chain
dal run multi_chain_operations.dal
dal run cross_chain_patterns.dal

# Web and APIs
dal run simple_web_api_example.dal
dal run web_framework_examples.dal

๐ŸŽ‰ Welcome to the DAL community! Let's build the future of decentralized applications together.

Next: Syntax Reference โ†’ | CLI Reference โ†’ | Standard Library โ†’