Skip to main content

Crate aingle_contracts

Crate aingle_contracts 

Source
Expand description

§AIngle Contracts - Smart Contract DSL and Runtime

A lightweight smart contract system for AIngle with:

  • Domain-specific language for contract definitions
  • WASM-based execution environment
  • Secure host functions for blockchain interaction
  • Efficient contract storage

§Contract Definition

use aingle_contracts::prelude::*;

// Define a simple token contract
let contract = ContractBuilder::new("token")
    .version("1.0.0")
    .state_schema(serde_json::json!({
        "balances": "map<address, u64>",
        "total_supply": "u64"
    }))
    .function("transfer", vec!["to", "amount"])
    .function("balance_of", vec!["address"])
    .build()
    .unwrap();

§Contract Execution

use aingle_contracts::prelude::*;

let runtime = ContractRuntime::new()?;
let result = runtime.call(&contract, "transfer", &["alice", "100"])?;

Re-exports§

pub use prelude::*;

Modules§

contract
Contract definition and DSL
error
Error types for contract operations
prelude
Commonly used types and traits
runtime
Contract runtime and WASM execution
storage
Contract storage abstraction
types
Core types for contracts