Source

Smart Contracts

WebAssembly contract execution engine with multi-language support

WebAssembly
Wasmtime
Multi-language
RocksDB
Multi-Language Support
Any language that compiles to WebAssembly
Rust, AssemblyScript, C/C++, Go, Zig, WAT
Standard WASM compilation targets
Gas Metering
Execution cost tracking and limits
2-4 YU per function call
Wasmtime fuel + custom gas schedule
Persistent Storage
RocksDB integration with isolation
Contract state persists across restarts
Each contract has separate namespace
Sandboxed Execution
Memory isolation and capability model
No access to host memory
Only approved host functions callable
Supported Languages
Any language with WebAssembly compilation support

Rust

wasm32-unknown-unknown
#[no_mangle]
pub extern "C" fn add(a: i32, b: i32) -> i32 {
    a + b
}
Full ecosystem support

AssemblyScript

TypeScript → WASM
export function fibonacci(n: i32): i32 {
    if (n <= 1) return n;
    return fibonacci(n - 1) + fibonacci(n - 2);
}
TypeScript-like syntax

C/C++

clang → WASM
int calculate_interest(int principal, int rate, int time) {
    return (principal * rate * time) / 100;
}
LLVM compilation

WAT

WebAssembly Text
(func (export "get_42") (result i32)
    i32.const 42
)
Hand-written WebAssembly
Host Functions
Blockchain interaction API available to contracts

Storage

storage_get(key_ptr, key_len) -> i64
storage_set(key_ptr, key_len, value_ptr, value_len)
storage_delete(key_ptr, key_len)

Blockchain Context

get_caller() -> u64
get_block_height() -> u64
get_block_timestamp() -> u64
get_contract_balance() -> u64

Cryptography

verify_signature(msg_ptr, msg_len, sig_ptr, sig_len) -> i32
hash_sha256(input_ptr, input_len, output_ptr)

Events

emit_event(topic_ptr, topic_len, data_ptr, data_len)
Gas Schedule
Execution costs for different operations
WASM instruction
Per instruction executed
1 gas
Storage read
Per storage_get() call
50 gas
Storage write
Per storage_set() call
1000 gas
Memory copy
Memory operations
1 gas/byte
Memory grow
Per 64KB page
100 gas/page
Host function
Base cost for host calls
10 gas
Crypto operation
Signature verification
500 gas
Contract Deployment
Deploy contracts via JSON-RPC 2.0
// Deploy contract via RPC
curl -X POST \
  -u "yprotocol:password" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "deploy_contract",
    "params": {
      "bytecode": "0061736d01000000...",  // WASM bytecode
      "deployer": "y_YourAddress"
    },
    "id": 1
  }' \
  http://localhost:8545/rpc

// Response
{
  "jsonrpc": "2.0",
  "result": {
    "contractAddress": "yc_6d3aff8ee1981d1f40985b332a4f4e93481e2eaf",
    "codeHash": "7db500c5f17976a02e1a116a5885be1b3c8611dc...",
    "gasUsed": 0,
    "status": "success"
  },
  "id": 1
}
Technical Specifications

Performance

  • • Contract execution: 2-4 gas per call
  • • Deployment time: <100ms
  • • Storage access: <1ms per operation
  • • Throughput: 1000+ calls/second

Limits

  • • Max module size: 1MB
  • • Memory limit: 1MB per contract
  • • Stack limit: 64KB (Wasmtime)
  • • Gas limit: 500k per function call
Test Coverage
37 tests covering all VM functionality
Contract compilation
Function execution
Gas metering
Storage persistence
Host function integration