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.
cargo install dist_agent_langgit clone https://github.com/okjason-source/dist_agent_lang.git
cd dist_agent_lang
cargo build --release
export PATH="$PWD/target/release:$PATH"Download from GitHub
Releases and extract the binary (dal or
dal.exe) to your PATH.
dal --version
# Expected: dist_agent_lang v1.0.8# Create your first DAL file
touch hello.dalCopy 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;
}
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!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!"
}
dal run greeting.dal# Run all tests in current directory
dal test
# Run tests for a specific file
dal test hello.dalCreate 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.daldal check hello.dal
# Validates syntax and type checkingdal parse hello.dal
# Shows parse tree and validates syntaxdal fmt hello.dal
# Formats your DAL code consistentlydal lint hello.dal
# Checks for common issues and best practicesCongratulations! You've just:
@trust, @secure,
@chain, etc.# 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# Clean and rebuild
cargo clean
cargo build --release# Check syntax
dal check hello.dal
# Parse with verbose output
dal parse hello.dal# Run with verbose logging
RUST_LOG=debug dal run hello.daldal repl
# Interactive shell for testing code snippetsdal watch hello.dal
# Auto-runs on file savedal new my-project
# Creates a new project structure
dal new my-ai --type ai
# Creates an AI-focused projectdal fmt hello.dal
# Ensures consistent code styleServices are the main building blocks in DAL:
@trust("hybrid")
@chain("ethereum")
service MyService {
count: int = 0;
fn increment() {
self.count = self.count + 1;
}
}
Use attributes to control behavior:
@trust("hybrid") - Hybrid trust model@trust("decentralized") - Fully decentralized@trust("centralized") - Centralized trust@chain("ethereum") - Target blockchain@secure - Enable security features@txn - Transaction context@limit(n) - Resource limitsDAL 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.
@trust("hybrid")
@chain("ethereum", "polygon", "arbitrum")
service MultiChainService {
// Automatically works across all specified chains!
}
@trust("hybrid")
@secure
service SecureService {
// Automatic:
// - Reentrancy protection
// - Safe math (overflow protection)
// - Audit logging
// - Capability checks
}
| 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 |
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 โ