Version: 1.0.8
Last Updated: 2026-02-06
Optimized for: AI/LLM code generation and human
reference
This document provides a comprehensive, machine-readable reference for all DAL standard library modules.
Format Convention:
function_name(param1: Type, param2: Type) -> ReturnType
Blockchain operations for deploying contracts, making calls, and managing assets.
chain::deploy(contract_name: String, constructor_args: String) -> Result<DeployResult, Error>
Deploy a smart contract to the blockchain.
Parameters:
contract_name: Name of the contract to deployconstructor_args: JSON string of constructor
argumentsReturns: Deployment result with contract address
Example:
let result = chain::deploy("MyToken", "{}");
log::info("Contract deployed at: " + result.address);
chain::call(contract_address: String, function_name: String, args: String) -> Result<CallResult, Error>
Call a function on a deployed contract.
Parameters:
contract_address: Address of the deployed contractfunction_name: Name of the function to callargs: JSON string of function argumentsReturns: Function call result
Example:
let result = chain::call("0x742d35...", "transfer", "{\"to\": \"0xabc\", \"amount\": 100}");
chain::get_balance(chain_id: Int, address: String) -> Int
Get the native token balance of an address.
Parameters:
chain_id: Blockchain chain ID (1=Ethereum, 137=Polygon,
etc.)address: Wallet address to queryReturns: Balance in wei (smallest denomination)
Example:
let balance = chain::get_balance(1, "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb");
log::info("Balance: " + balance);
chain::get_gas_price(chain_id: Int) -> Int
Get current gas price for a chain.
Returns: Gas price in gwei
chain::estimate_gas(chain_id: Int, operation: String) -> Int
Estimate gas cost for an operation.
Returns: Estimated gas units
chain::get_transaction_status(chain_id: Int, tx_hash: String) -> String
Get status of a transaction.
Returns: Status string ("pending", "confirmed", "failed")
chain::get_block_timestamp(chain_id: Int) -> Int
Get latest block timestamp.
Returns: Unix timestamp
chain::mint(name: String) -> String
Mint an on-chain asset.
Returns: Asset ID
chain::get(asset_id: String) -> Map<String, Value>
Get asset information.
Returns: Asset metadata
chain::get_chain_config(chain_id: Int) -> Map<String, Value>
Get blockchain configuration.
Returns: Configuration map
chain::get_supported_chains() -> List<Map<String, Value>>
Get list of supported blockchains.
Returns: List of chain configs
Cryptographic operations including hashing, signing, and encryption.
crypto::hash(data: String, algorithm: String) -> String
Hash data using specified algorithm.
Parameters:
data: Data to hashalgorithm: "sha256" or "sha512"Returns: Hex-encoded hash
Example:
let hash = crypto::hash("hello world", "sha256");
crypto::sign(data: String, private_key: String) -> String
Sign data with private key.
Returns: Signature (hex-encoded)
crypto::verify(data: String, signature: String, public_key: String) -> Bool
Verify signature.
Returns: True if valid
crypto::generate_keypair(algorithm: String) -> Map<String, String>
Generate public/private keypair.
Parameters:
algorithm: "rsa" or "ed25519"Returns: Map with "public" and "private" keys
crypto::encrypt(data: String, public_key: String) -> String
Encrypt data with public key.
Returns: Encrypted data (base64)
crypto::decrypt(encrypted_data: String, private_key: String) -> String
Decrypt data with private key.
Returns: Original data
crypto::encrypt_aes256(data: String, key: String) -> String
Encrypt with AES-256.
Returns: Encrypted data
crypto::decrypt_aes256(encrypted_data: String, key: String) -> String
Decrypt with AES-256.
Returns: Decrypted data
crypto::random_hash(algorithm: String) -> String
Generate random hash.
Returns: Random hash string
Authentication and user management.
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");
auth::login(username: String, password: String) -> String
Authenticate user.
Returns: Session token
auth::validate_token(token: String) -> Bool
Validate session token.
Returns: True if valid
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.
auth::init_auth_system() -> Bool
Initialize authentication system.
Returns: Success status
Database operations for querying, migrations, and management.
db::connect(connection_string: String) -> String
Connect to database.
Returns: Connection ID
Example:
let conn = db::connect("postgresql://localhost:5432/mydb");
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");
db::execute(conn: String, sql: String) -> Int
Execute SQL statement (INSERT, UPDATE, DELETE).
Returns: Number of affected rows
db::list_tables(conn: String) -> List<String>
List all tables.
Returns: Table names
db::get_table_schema(conn: String, table_name: String) -> Map<String, Value>
Get table schema.
Returns: Schema information
db::get_query_plan(conn: String, sql: String) -> String
Get query execution plan.
Returns: Query plan
db::backup_database(conn: String, backup_path: String) -> Bool
Backup database.
Returns: Success status
db::restore_database(conn: String, backup_path: String) -> Bool
Restore from backup.
Returns: Success status
db::apply_migration(conn: String, migration_sql: String) -> Bool
Apply database migration.
Returns: Success status
db::rollback_migration(conn: String, version: String) -> Bool
Rollback migration.
Returns: Success status
db::ping_database(conn: String) -> Bool
Check database connectivity.
Returns: True if connected
db::get_database_metrics(conn: String) -> Map<String, Value>
Get database metrics.
Returns: Metrics map (connections, queries/sec, etc.)
AI agent orchestration, coordination, and communication.
agent::spawn(config: Map<String, Value>) -> AgentContext
Create a new agent.
Parameters:
config: Agent configuration map with:
name: Agent nametype: "ai", "system", "worker", or "custom:role: Agent role descriptioncapabilities: List of capabilitiestrust_level: "standard", "high", or "critical"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);
agent::coordinate(agent_id: String, task: AgentTask, coordination_type: String) -> Bool
Coordinate agent activities.
Parameters:
agent_id: Target agent IDtask: Task objectcoordination_type: "task_distribution",
"resource_sharing", or "conflict_resolution"Returns: Success status
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);
agent::evolve(agent_id: String, evolution_data: Map<String, Value>) -> Bool
Update agent through learning.
Returns: Success status
agent::validate_capabilities(agent_type: String, required_capabilities: List<String>) -> Bool
Validate agent has required capabilities.
Returns: True if capable
agent::create_agent_config(name: String, agent_type: String, role: String) -> AgentConfig
Create agent configuration.
Returns: Config object
agent::create_agent_task(task_id: String, description: String, priority: String) -> AgentTask
Create agent task.
Parameters:
priority: "low", "medium", "high", or "critical"Returns: Task object
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
agent::receive_pending_tasks(agent_id: String) -> List<AgentTask>
Get pending tasks for agent.
Returns: List of tasks
agent::receive_messages(agent_id: String) -> List<AgentMessage>
Get messages for agent.
Returns: List of messages
Load and spawn agents from mold files (reusable agent configurations). Supports local paths, IPFS, and on-chain molds.
mold::load(source: String) -> Map<String, Value>
Load mold config from path, name, or ipfs://cid. Returns
config map with name, version, agent {...}.
Parameters:
source: Path, mold name (e.g.
"verify_mold"), or ipfs://Qm...Returns: Config map (name, version, agent {...})
Example:
let config = mold::load("verify_mold");
log::info("Mold: " + config.name + " v" + config.version);
mold::spawn_from(source: String, name_override?: String) -> String
Load mold and spawn agent. Returns agent_id.
Parameters:
source: Path, mold name, or
ipfs://cidname_override: Optional agent name (else uses mold
name)Returns: agent_id
Example:
let agent_id = mold::spawn_from("verify_mold", "MyAgent");
mold::list() -> List<String>
List local mold file paths (base, mold/, mold/samples).
Returns: List of path strings
Example:
let paths = mold::list();
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:
mold_id: On-chain mold NFT IDReturns: Map with creator, ipfs_hash, mint_fee, mint_count, max_use_count, active, created_at, updated_at
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:
mold_id: On-chain mold NFT IDname_override: Optional agent nameReturns: agent_id
Example:
let agent_id = mold::use_mold(123, "OnChainAgent");
AI and machine learning operations.
ai::generate_text(prompt: String) -> String
Generate text from prompt.
Returns: Generated text
ai::classify(model: String, input: String) -> String
Classify input with model.
Returns: Classification result
ai::embed(text: String) -> List<Float>
Get embedding vector for text.
Returns: Embedding vector
ai::cosine_similarity(vec1: List<Float>, vec2: List<Float>) -> Float
Calculate cosine similarity.
Returns: Similarity score (-1 to 1)
ai::analyze_text(text: String) -> Map<String, Value>
Analyze text (sentiment, entities, etc.).
Returns: Analysis results
ai::analyze_image_url(url: String) -> Map<String, Value>
Analyze image from URL.
Returns: Analysis results
IoT device management and sensor operations.
iot::register_device(device_config: Map<String, Value>) -> String
Register IoT device.
Returns: Device ID
iot::connect_device(device_id: String) -> Bool
Connect to device.
Returns: Success status
iot::get_device_status(device_id: String) -> String
Get device status.
Returns: Status ("online", "offline", "error")
iot::read_sensor_data(sensor_id: String) -> Map<String, Value>
Read sensor data.
Returns: Sensor readings
iot::send_actuator_command(actuator_id: String, command: String) -> Bool
Send command to actuator.
Returns: Success status
iot::monitor_power_consumption(device_id: String) -> Float
Monitor device power usage.
Returns: Power consumption (watts)
iot::optimize_power_usage(device_id: String, target_hours: Int) -> String
Optimize power usage.
Returns: Optimization result
iot::detect_sensor_anomalies(sensor_data: Map<String, Value>) -> String
Detect anomalies in sensor data.
Returns: Anomaly report
iot::predict_device_failure(device_id: String, historical_data: Map<String, Value>) -> Float
Predict device failure probability.
Returns: Failure probability (0-1)
Oracle data feed operations.
oracle::fetch(source: String, query_type: String) -> Map<String, Value>
Fetch data from oracle.
Returns: Oracle data
oracle::stream(source: String, callback: String) -> String
Create data stream from oracle.
Returns: Stream ID
oracle::get_stream(stream_id: String) -> Map<String, Value>
Get stream status.
Returns: Stream info
oracle::close_stream(stream_id: String) -> Bool
Close data stream.
Returns: Success status
oracle::create_source(name: String, url: String) -> String
Create oracle source.
Returns: Source ID
oracle::verify(data: Map<String, Value>, signature: String) -> Bool
Verify oracle data signature.
Returns: True if valid
HTTP operations for web requests and responses.
web::get_request(url: String) -> String
HTTP GET request.
Returns: Response body
web::post_request(url: String, data: String) -> String
HTTP POST request.
Returns: Response body
web::parse_url(url: String) -> Map<String, String>
Parse URL into components.
Returns: Map with scheme, host, path, query, etc.
web::render_template(template: String, variables: Map<String, Value>) -> String
Render template with variables.
Returns: Rendered HTML
Logging operations.
log::info(message: String)
log::info(source: String, message: String)
Log info message.
log::warn(message: String)
log::warn(source: String, message: String)
Log warning message.
log::error(message: String)
log::error(source: String, message: String)
Log error message.
log::debug(message: String)
log::debug(source: String, message: String)
Log debug message.
log::audit(event: String, data: Map<String, Value>)
log::audit(source: String, event: String, data: Map<String, Value>)
Log audit event.
log::get_stats() -> Map<String, Int>
Get logging statistics.
Returns: Stats (total logs, by level, etc.)
log::get_entries() -> List<Map<String, Value>>
Get recent log entries.
Returns: Log entries
log::get_entries_by_level(level: String) -> List<Map<String, Value>>
Get logs by level.
Returns: Filtered log entries
log::clear()
Clear all logs.
Configuration management.
config::get_env(key: String) -> String
Get environment variable.
Returns: Value or empty string
config::get_database_config() -> Map<String, Value>
Get database configuration.
Returns: DB config
config::get_api_config() -> Map<String, Value>
Get API configuration.
Returns: API config
config::get_blockchain_config() -> Map<String, Value>
Get blockchain configuration.
Returns: Blockchain config
config::get_ai_config() -> Map<String, Value>
Get AI configuration.
Returns: AI config
Cloud administration and governance.
cloudadmin::authorize(admin_id: String, operation: String, resource: String) -> Bool
Check authorization.
Returns: True if authorized
cloudadmin::enforce_policy(policy_name: String, context: AdminContext) -> Bool
Enforce admin policy.
Returns: True if allowed
cloudadmin::validate_hybrid_trust(admin_trust: String, user_trust: String) -> Bool
Validate hybrid trust.
Returns: True if valid
cloudadmin::bridge_trusts(centralized_trust: String, decentralized_trust: String) -> Bool
Bridge trust models.
Returns: True if bridged
Trust and permission management.
trust::authorize(admin_id: String, operation: String, resource: String) -> Bool
Authorize operation.
Returns: True if authorized
trust::enforce_policy(policy_name: String, context: AdminContext) -> Bool
Enforce policy.
Returns: True if allowed
trust::validate_hybrid_trust(admin_trust: String, user_trust: String) -> Bool
Validate hybrid trust.
Returns: True if valid
trust::bridge_trusts(centralized_trust: String, decentralized_trust: String) -> Bool
Bridge trust models.
Returns: True if bridged
trust::register_admin(admin_id: String, level: String, permissions: List<String>)
Register admin user.
Parameters:
level: "user", "moderator", "admin", or
"superadmin"Capability-based access control (keys to resources).
key::create(resource: String, permissions: List<String>) -> Capability
Create key (capability).
Returns: Capability
key::check(request: CapabilityRequest) -> Bool
Check if operation is allowed.
Returns: True if allowed
key::create_principal(principal_id: String, name: String) -> Principal
Create security principal.
Returns: Principal
Anti-money laundering checks.
aml::perform_check(transaction: Map<String, Value>, address: String) -> String
Perform AML check.
Returns: Check ID
aml::get_check_status(check_id: String) -> String
Get check status.
Returns: Status ("pending", "passed", "failed")
aml::list_providers() -> List<String>
List AML providers.
Returns: Provider names
Know Your Customer verification.
kyc::verify(user_id: String, verification_data: Map<String, Value>) -> String
Verify user identity.
Returns: Verification ID
kyc::get_verification_status(verification_id: String) -> String
Get verification status.
Returns: Status ("pending", "verified", "rejected")
Testing framework.
test::run_registered_tests() -> Map<String, Value>
Run all registered tests.
Returns: Test results
test::get_test_suites() -> List<String>
Get test suite names.
Returns: Suite names
test::get_results() -> Map<String, Value>
Get last test results.
Returns: Results
// 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 }
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);
}
Always import modules:
import stdlib::chain;
import stdlib::agent;Use try-catch for error handling:
try {
// risky operation
} catch error {
log::error("Error: " + error);
}Leverage built-in functions:
crypto::hash()web::get_request()auth::create_user()Use services for stateful components:
@chain("ethereum")
service MyContract {
var state: String = "initial";
function update() {
state = "updated";
}
}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)