DAL Standard Library Reference

Version: 1.0.8
Last Updated: 2026-02-06
Optimized for: AI/LLM code generation and human reference


Overview

This document provides a comprehensive, machine-readable reference for all DAL standard library modules.

Format Convention:

function_name(param1: Type, param2: Type) -> ReturnType

Index


chain Module

Blockchain operations for deploying contracts, making calls, and managing assets.

Functions

deploy

chain::deploy(contract_name: String, constructor_args: String) -> Result<DeployResult, Error>

Deploy a smart contract to the blockchain.

Parameters:

Returns: Deployment result with contract address

Example:

let result = chain::deploy("MyToken", "{}");
log::info("Contract deployed at: " + result.address);

call

chain::call(contract_address: String, function_name: String, args: String) -> Result<CallResult, Error>

Call a function on a deployed contract.

Parameters:

Returns: Function call result

Example:

let result = chain::call("0x742d35...", "transfer", "{\"to\": \"0xabc\", \"amount\": 100}");

get_balance

chain::get_balance(chain_id: Int, address: String) -> Int

Get the native token balance of an address.

Parameters:

Returns: Balance in wei (smallest denomination)

Example:

let balance = chain::get_balance(1, "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb");
log::info("Balance: " + balance);

get_gas_price

chain::get_gas_price(chain_id: Int) -> Int

Get current gas price for a chain.

Returns: Gas price in gwei


estimate_gas

chain::estimate_gas(chain_id: Int, operation: String) -> Int

Estimate gas cost for an operation.

Returns: Estimated gas units


get_transaction_status

chain::get_transaction_status(chain_id: Int, tx_hash: String) -> String

Get status of a transaction.

Returns: Status string ("pending", "confirmed", "failed")


get_block_timestamp

chain::get_block_timestamp(chain_id: Int) -> Int

Get latest block timestamp.

Returns: Unix timestamp


mint

chain::mint(name: String) -> String

Mint an on-chain asset.

Returns: Asset ID


get

chain::get(asset_id: String) -> Map<String, Value>

Get asset information.

Returns: Asset metadata


get_chain_config

chain::get_chain_config(chain_id: Int) -> Map<String, Value>

Get blockchain configuration.

Returns: Configuration map


get_supported_chains

chain::get_supported_chains() -> List<Map<String, Value>>

Get list of supported blockchains.

Returns: List of chain configs


crypto Module

Cryptographic operations including hashing, signing, and encryption.

Functions

hash

crypto::hash(data: String, algorithm: String) -> String

Hash data using specified algorithm.

Parameters:

Returns: Hex-encoded hash

Example:

let hash = crypto::hash("hello world", "sha256");

sign

crypto::sign(data: String, private_key: String) -> String

Sign data with private key.

Returns: Signature (hex-encoded)


verify

crypto::verify(data: String, signature: String, public_key: String) -> Bool

Verify signature.

Returns: True if valid


generate_keypair

crypto::generate_keypair(algorithm: String) -> Map<String, String>

Generate public/private keypair.

Parameters:

Returns: Map with "public" and "private" keys


encrypt

crypto::encrypt(data: String, public_key: String) -> String

Encrypt data with public key.

Returns: Encrypted data (base64)


decrypt

crypto::decrypt(encrypted_data: String, private_key: String) -> String

Decrypt data with private key.

Returns: Original data


encrypt_aes256

crypto::encrypt_aes256(data: String, key: String) -> String

Encrypt with AES-256.

Returns: Encrypted data


decrypt_aes256

crypto::decrypt_aes256(encrypted_data: String, key: String) -> String

Decrypt with AES-256.

Returns: Decrypted data


random_hash

crypto::random_hash(algorithm: String) -> String

Generate random hash.

Returns: Random hash string


auth Module

Authentication and user management.

Functions

create_user

auth::create_user(username: String, password: String, email: String) -> String

Create a new user.

Returns: User ID

Example:

let user_id = auth::create_user("alice", "password123", "alice@example.com");

login

auth::login(username: String, password: String) -> String

Authenticate user.

Returns: Session token


validate_token

auth::validate_token(token: String) -> Bool

Validate session token.

Returns: True if valid


session

auth::session() -> Map<String, Value>
auth::session(user_id: String) -> Map<String, Value>

Get current session information.

Returns: Session map with user_id, timestamp, etc.


init_auth_system

auth::init_auth_system() -> Bool

Initialize authentication system.

Returns: Success status


db Module

Database operations for querying, migrations, and management.

Functions

connect

db::connect(connection_string: String) -> String

Connect to database.

Returns: Connection ID

Example:

let conn = db::connect("postgresql://localhost:5432/mydb");

query

db::query(conn: String, sql: String) -> List<Map<String, Value>>

Execute SQL query.

Returns: Result rows

Example:

let users = db::query(conn, "SELECT * FROM users");

execute

db::execute(conn: String, sql: String) -> Int

Execute SQL statement (INSERT, UPDATE, DELETE).

Returns: Number of affected rows


list_tables

db::list_tables(conn: String) -> List<String>

List all tables.

Returns: Table names


get_table_schema

db::get_table_schema(conn: String, table_name: String) -> Map<String, Value>

Get table schema.

Returns: Schema information


get_query_plan

db::get_query_plan(conn: String, sql: String) -> String

Get query execution plan.

Returns: Query plan


backup_database

db::backup_database(conn: String, backup_path: String) -> Bool

Backup database.

Returns: Success status


restore_database

db::restore_database(conn: String, backup_path: String) -> Bool

Restore from backup.

Returns: Success status


apply_migration

db::apply_migration(conn: String, migration_sql: String) -> Bool

Apply database migration.

Returns: Success status


rollback_migration

db::rollback_migration(conn: String, version: String) -> Bool

Rollback migration.

Returns: Success status


ping_database

db::ping_database(conn: String) -> Bool

Check database connectivity.

Returns: True if connected


get_database_metrics

db::get_database_metrics(conn: String) -> Map<String, Value>

Get database metrics.

Returns: Metrics map (connections, queries/sec, etc.)


agent Module

AI agent orchestration, coordination, and communication.

Functions

spawn

agent::spawn(config: Map<String, Value>) -> AgentContext

Create a new agent.

Parameters:

Returns: Agent context with agent_id

Example:

let agent = agent::spawn({
    "name": "FraudDetector",
    "type": "ai",
    "role": "Detect fraudulent transactions",
    "capabilities": ["fraud_detection", "pattern_analysis"],
    "trust_level": "high"
});
log::info("Agent created: " + agent.agent_id);

coordinate

agent::coordinate(agent_id: String, task: AgentTask, coordination_type: String) -> Bool

Coordinate agent activities.

Parameters:

Returns: Success status


communicate

agent::communicate(sender_id: String, receiver_id: String, message: AgentMessage) -> Bool

Send message between agents.

Returns: Success status

Example:

let msg = agent::create_agent_message(
    "msg_001",
    sender_id,
    receiver_id,
    "task_assignment",
    "Process batch 42"
);
agent::communicate(sender_id, receiver_id, msg);

evolve

agent::evolve(agent_id: String, evolution_data: Map<String, Value>) -> Bool

Update agent through learning.

Returns: Success status


validate_capabilities

agent::validate_capabilities(agent_type: String, required_capabilities: List<String>) -> Bool

Validate agent has required capabilities.

Returns: True if capable


create_agent_config

agent::create_agent_config(name: String, agent_type: String, role: String) -> AgentConfig

Create agent configuration.

Returns: Config object


create_agent_task

agent::create_agent_task(task_id: String, description: String, priority: String) -> AgentTask

Create agent task.

Parameters:

Returns: Task object


create_agent_message

agent::create_agent_message(
    message_id: String,
    sender_id: String,
    receiver_id: String,
    message_type: String,
    content: Value
) -> AgentMessage

Create agent message.

Returns: Message object


receive_pending_tasks

agent::receive_pending_tasks(agent_id: String) -> List<AgentTask>

Get pending tasks for agent.

Returns: List of tasks


receive_messages

agent::receive_messages(agent_id: String) -> List<AgentMessage>

Get messages for agent.

Returns: List of messages


mold Module

Load and spawn agents from mold files (reusable agent configurations). Supports local paths, IPFS, and on-chain molds.

Functions

load

mold::load(source: String) -> Map<String, Value>

Load mold config from path, name, or ipfs://cid. Returns config map with name, version, agent {...}.

Parameters:

Returns: Config map (name, version, agent {...})

Example:

let config = mold::load("verify_mold");
log::info("Mold: " + config.name + " v" + config.version);

spawn_from

mold::spawn_from(source: String, name_override?: String) -> String

Load mold and spawn agent. Returns agent_id.

Parameters:

Returns: agent_id

Example:

let agent_id = mold::spawn_from("verify_mold", "MyAgent");

list

mold::list() -> List<String>

List local mold file paths (base, mold/, mold/samples).

Returns: List of path strings

Example:

let paths = mold::list();

get_info

mold::get_info(mold_id: Int) -> Map<String, Value>

Get on-chain mold info (creator, ipfs_hash, mint_fee, mint_count, etc.). Requires web3 feature.

Parameters:

Returns: Map with creator, ipfs_hash, mint_fee, mint_count, max_use_count, active, created_at, updated_at


use_mold

mold::use_mold(mold_id: Int, name_override?: String) -> String

Use on-chain mold: pay mint fee, enforce cap, load from IPFS, spawn agent. Requires web3 feature and MoldRegistry deployed.

Parameters:

Returns: agent_id

Example:

let agent_id = mold::use_mold(123, "OnChainAgent");

ai Module

AI and machine learning operations.

Functions

generate_text

ai::generate_text(prompt: String) -> String

Generate text from prompt.

Returns: Generated text


classify

ai::classify(model: String, input: String) -> String

Classify input with model.

Returns: Classification result


embed

ai::embed(text: String) -> List<Float>

Get embedding vector for text.

Returns: Embedding vector


cosine_similarity

ai::cosine_similarity(vec1: List<Float>, vec2: List<Float>) -> Float

Calculate cosine similarity.

Returns: Similarity score (-1 to 1)


analyze_text

ai::analyze_text(text: String) -> Map<String, Value>

Analyze text (sentiment, entities, etc.).

Returns: Analysis results


analyze_image_url

ai::analyze_image_url(url: String) -> Map<String, Value>

Analyze image from URL.

Returns: Analysis results


iot Module

IoT device management and sensor operations.

Functions

register_device

iot::register_device(device_config: Map<String, Value>) -> String

Register IoT device.

Returns: Device ID


connect_device

iot::connect_device(device_id: String) -> Bool

Connect to device.

Returns: Success status


get_device_status

iot::get_device_status(device_id: String) -> String

Get device status.

Returns: Status ("online", "offline", "error")


read_sensor_data

iot::read_sensor_data(sensor_id: String) -> Map<String, Value>

Read sensor data.

Returns: Sensor readings


send_actuator_command

iot::send_actuator_command(actuator_id: String, command: String) -> Bool

Send command to actuator.

Returns: Success status


monitor_power_consumption

iot::monitor_power_consumption(device_id: String) -> Float

Monitor device power usage.

Returns: Power consumption (watts)


optimize_power_usage

iot::optimize_power_usage(device_id: String, target_hours: Int) -> String

Optimize power usage.

Returns: Optimization result


detect_sensor_anomalies

iot::detect_sensor_anomalies(sensor_data: Map<String, Value>) -> String

Detect anomalies in sensor data.

Returns: Anomaly report


predict_device_failure

iot::predict_device_failure(device_id: String, historical_data: Map<String, Value>) -> Float

Predict device failure probability.

Returns: Failure probability (0-1)


oracle Module

Oracle data feed operations.

Functions

fetch

oracle::fetch(source: String, query_type: String) -> Map<String, Value>

Fetch data from oracle.

Returns: Oracle data


stream

oracle::stream(source: String, callback: String) -> String

Create data stream from oracle.

Returns: Stream ID


get_stream

oracle::get_stream(stream_id: String) -> Map<String, Value>

Get stream status.

Returns: Stream info


close_stream

oracle::close_stream(stream_id: String) -> Bool

Close data stream.

Returns: Success status


create_source

oracle::create_source(name: String, url: String) -> String

Create oracle source.

Returns: Source ID


verify

oracle::verify(data: Map<String, Value>, signature: String) -> Bool

Verify oracle data signature.

Returns: True if valid


web Module

HTTP operations for web requests and responses.

Functions

get_request

web::get_request(url: String) -> String

HTTP GET request.

Returns: Response body


post_request

web::post_request(url: String, data: String) -> String

HTTP POST request.

Returns: Response body


parse_url

web::parse_url(url: String) -> Map<String, String>

Parse URL into components.

Returns: Map with scheme, host, path, query, etc.


render_template

web::render_template(template: String, variables: Map<String, Value>) -> String

Render template with variables.

Returns: Rendered HTML


log Module

Logging operations.

Functions

info

log::info(message: String)
log::info(source: String, message: String)

Log info message.


warn

log::warn(message: String)
log::warn(source: String, message: String)

Log warning message.


error

log::error(message: String)
log::error(source: String, message: String)

Log error message.


debug

log::debug(message: String)
log::debug(source: String, message: String)

Log debug message.


audit

log::audit(event: String, data: Map<String, Value>)
log::audit(source: String, event: String, data: Map<String, Value>)

Log audit event.


get_stats

log::get_stats() -> Map<String, Int>

Get logging statistics.

Returns: Stats (total logs, by level, etc.)


get_entries

log::get_entries() -> List<Map<String, Value>>

Get recent log entries.

Returns: Log entries


get_entries_by_level

log::get_entries_by_level(level: String) -> List<Map<String, Value>>

Get logs by level.

Returns: Filtered log entries


clear

log::clear()

Clear all logs.


config Module

Configuration management.

Functions

get_env

config::get_env(key: String) -> String

Get environment variable.

Returns: Value or empty string


get_database_config

config::get_database_config() -> Map<String, Value>

Get database configuration.

Returns: DB config


get_api_config

config::get_api_config() -> Map<String, Value>

Get API configuration.

Returns: API config


get_blockchain_config

config::get_blockchain_config() -> Map<String, Value>

Get blockchain configuration.

Returns: Blockchain config


get_ai_config

config::get_ai_config() -> Map<String, Value>

Get AI configuration.

Returns: AI config


cloudadmin Module

Cloud administration and governance.

Functions

authorize

cloudadmin::authorize(admin_id: String, operation: String, resource: String) -> Bool

Check authorization.

Returns: True if authorized


enforce_policy

cloudadmin::enforce_policy(policy_name: String, context: AdminContext) -> Bool

Enforce admin policy.

Returns: True if allowed


validate_hybrid_trust

cloudadmin::validate_hybrid_trust(admin_trust: String, user_trust: String) -> Bool

Validate hybrid trust.

Returns: True if valid


bridge_trusts

cloudadmin::bridge_trusts(centralized_trust: String, decentralized_trust: String) -> Bool

Bridge trust models.

Returns: True if bridged


trust Module

Trust and permission management.

Functions

authorize

trust::authorize(admin_id: String, operation: String, resource: String) -> Bool

Authorize operation.

Returns: True if authorized


enforce_policy

trust::enforce_policy(policy_name: String, context: AdminContext) -> Bool

Enforce policy.

Returns: True if allowed


validate_hybrid_trust

trust::validate_hybrid_trust(admin_trust: String, user_trust: String) -> Bool

Validate hybrid trust.

Returns: True if valid


bridge_trusts

trust::bridge_trusts(centralized_trust: String, decentralized_trust: String) -> Bool

Bridge trust models.

Returns: True if bridged


register_admin

trust::register_admin(admin_id: String, level: String, permissions: List<String>)

Register admin user.

Parameters:


key Module

Capability-based access control (keys to resources).

Functions

create

key::create(resource: String, permissions: List<String>) -> Capability

Create key (capability).

Returns: Capability


check

key::check(request: CapabilityRequest) -> Bool

Check if operation is allowed.

Returns: True if allowed


create_principal

key::create_principal(principal_id: String, name: String) -> Principal

Create security principal.

Returns: Principal


aml Module

Anti-money laundering checks.

Functions

perform_check

aml::perform_check(transaction: Map<String, Value>, address: String) -> String

Perform AML check.

Returns: Check ID


get_check_status

aml::get_check_status(check_id: String) -> String

Get check status.

Returns: Status ("pending", "passed", "failed")


list_providers

aml::list_providers() -> List<String>

List AML providers.

Returns: Provider names


kyc Module

Know Your Customer verification.

Functions

verify

kyc::verify(user_id: String, verification_data: Map<String, Value>) -> String

Verify user identity.

Returns: Verification ID


get_verification_status

kyc::get_verification_status(verification_id: String) -> String

Get verification status.

Returns: Status ("pending", "verified", "rejected")


test Module

Testing framework.

Functions

run_registered_tests

test::run_registered_tests() -> Map<String, Value>

Run all registered tests.

Returns: Test results


get_test_suites

test::get_test_suites() -> List<String>

Get test suite names.

Returns: Suite names


get_results

test::get_results() -> Map<String, Value>

Get last test results.

Returns: Results


Type Definitions

Common Types

// Agent Types
type AgentContext = Map<String, Value>
type AgentConfig = Map<String, Value>
type AgentTask = Map<String, Value>
type AgentMessage = Map<String, Value>

// Admin Types
type AdminContext = Map<String, Value>

// Capability Types
type CapabilityRequest = Map<String, Value>

// Result Types
type DeployResult = Map<String, Value>  // { address: String, tx_hash: String }
type CallResult = Map<String, Value>    // { success: Bool, result: Value }

Error Handling

All functions that can fail return Result<T, Error> or throw runtime errors. Use try-catch for error handling:

try {
    let result = chain::deploy("MyContract", "{}");
    log::info("Success: " + result.address);
} catch error {
    log::error("Failed: " + error);
}

Best Practices for AI/LLM Code Generation

  1. Always import modules:

    import stdlib::chain;
    import stdlib::agent;
  2. Use try-catch for error handling:

    try {
        // risky operation
    } catch error {
        log::error("Error: " + error);
    }
  3. Leverage built-in functions:

  4. Use services for stateful components:

    @chain("ethereum")
    service MyContract {
        var state: String = "initial";
        
        function update() {
            state = "updated";
        }
    }
  5. Follow attribute patterns:

    @trust("hybrid")
    @chain("ethereum")
    @ai
    service SmartAgent { }

Document Version: 1.0
Last Updated for AI Training: 2026-02-06
Machine-Readable Format: Yes
Status: Beta (v1.0.8)