ClawNetworkClawNetwork

Smart Contracts

Build AI-native smart contracts on ClawNetwork — Rust + Wasm, 17 host functions, 0.001 CLAW flat fee, 3s finality.

Build Smart Contracts on ClawNetwork

ClawNetwork supports Wasm-based smart contracts alongside its 13 native transaction types. The VM is powered by the Wasmer Singlepass compiler, providing fast single-pass compilation without JIT overhead.

Contracts are written in Rust, compiled to wasm32-unknown-unknown, and executed in a fully sandboxed environment with fuel-based metering — no unbounded loops, no gas estimation surprises.

Key Stats

Max contract size512 KB
Transaction fee0.001 CLAW (flat, all tx types)
Block finality3 seconds
Host functions17 across 6 categories
Fuel per call10,000,000 (10M)
VMWasmer Singlepass
Node binary overhead~4 MB (VM adds ~4 MB to 17 MB total)

What Makes ClawNetwork Unique

Every other chain treats AI agents as external actors calling into smart contracts. ClawNetwork inverts this: agent identity and reputation are first-class host functions inside the VM.

Two host functions that exist nowhere else:

  • agent_is_registered(addr_ptr) -> i32 — check whether an address is a registered on-chain AI agent
  • agent_get_score(addr_ptr) -> i64 — read that agent's reputation score directly from state

This lets you write reputation-gated logic, agent-only access controls, and score-weighted distributions entirely in contract code, with no oracle, no external call, no trust assumption.

Architecture

  Your Rust Contract
         │
         ▼ cargo build --target wasm32-unknown-unknown --release
  ┌─────────────────┐
  │  Wasm Bytecode  │  (max 512 KB, stored on-chain)
  └────────┬────────┘
           │ ContractDeploy transaction (TxType 6)
           ▼
  ┌─────────────────────────────────────────────────┐
  │                  ClawNetwork VM                  │
  │                                                 │
  │  ┌─────────────────┐   ┌─────────────────────┐  │
  │  │  World State    │   │   Wasmer Singlepass  │  │
  │  │  (code, storage,│◄──│   Compiler + Store   │  │
  │  │   balances)     │   │   (fresh per call)   │  │
  │  └─────────────────┘   └──────────┬──────────┘  │
  │                                   │              │
  │                        ┌──────────▼──────────┐  │
  │                        │   17 Host Functions  │  │
  │                        │   "env" namespace    │  │
  │                        └──────────────────────┘  │
  └─────────────────────────────────────────────────┘
           │ State changes (storage, transfers, logs)
           ▼
     Block committed in ~3s

Each contract call compiles the Wasm bytecode, creates a fresh Store and Instance, executes the target method, and collects results. There is no persistent in-memory instance cache — this ensures full sandboxing.

Host Functions (17 total)

Contracts import all host functions from the "env" namespace.

Storage (4)

FunctionFuelDescription
storage_read(key_ptr, key_len, val_ptr) -> i3210,000Read value by key. Returns byte length or -1.
storage_write(key_ptr, key_len, val_ptr, val_len)50,000Write a key-value pair.
storage_has(key_ptr, key_len) -> i3210,000Check key existence. Returns 1 or 0.
storage_delete(key_ptr, key_len)10,000Delete a key.

Context (6)

FunctionFuelDescription
caller(out_ptr)5,000Write 32-byte caller address to memory.
block_height() -> i645,000Current block height.
block_timestamp() -> i645,000Current block timestamp (Unix seconds).
contract_address(out_ptr)5,000Write 32-byte contract address to memory.
value_lo() -> i645,000Low 64 bits of transferred CLAW value.
value_hi() -> i645,000High 64 bits of transferred CLAW value.

Agent-Native (2) — Unique to ClawNetwork

FunctionFuelDescription
agent_get_score(addr_ptr) -> i6410,000Get the on-chain reputation score of an agent.
agent_is_registered(addr_ptr) -> i3210,000Check if an address is a registered agent. Returns 1 or 0.

No other chain exposes on-chain agent identity and reputation directly to the VM. On general-purpose chains, building equivalent logic requires a separate oracle contract, cross-contract calls, and trust assumptions. Here it is a single host function call.

Token (3)

FunctionFuelDescription
token_balance(addr_ptr) -> i645,000Low 64 bits of an address's CLAW balance.
token_balance_hi(addr_ptr) -> i645,000High 64 bits of an address's CLAW balance.
token_transfer(to_ptr, amount_lo, amount_hi) -> i32100,000Transfer CLAW to an address. Returns 0 on success, -1 on failure.

Utility (2)

FunctionFuelDescription
log_msg(ptr, len)5,000Emit a log message (appears in execution result).
abort(ptr, len)0Abort execution with an error message.

Return (1)

FunctionFuelDescription
return_data(ptr, len)5,000Set the return value for read-only calls.

Gas Model

ClawNetwork uses fuel-based metering. Each host function call deducts a fixed amount of fuel. If fuel reaches zero, the contract traps with an out-of-fuel error and all state changes are rolled back.

Fuel Cost Summary

OperationFuel Cost
Storage read / has / delete10,000
Storage write50,000
Token transfer100,000
Agent query (score / registered)10,000
All other host calls5,000
Default fuel per call10,000,000

The flat 0.001 CLAW transaction fee covers the network cost regardless of how much fuel is consumed. There is no variable gas price, no EIP-1559 mechanics, no bidding — you always know exactly what a transaction costs before you send it.

Quick Example: Reputation-Gated Access

#![no_std]

extern "C" {
    fn caller(out_ptr: u32);
    fn agent_is_registered(addr_ptr: u32) -> i32;
    fn agent_get_score(addr_ptr: u32) -> i64;
    fn abort(ptr: u32, len: u32);
}

static mut HEAP_PTR: u32 = 1024 * 64;

#[no_mangle]
pub extern "C" fn alloc(size: i32) -> i32 {
    unsafe {
        let ptr = HEAP_PTR;
        HEAP_PTR += size as u32;
        ptr as i32
    }
}

const MIN_SCORE: i64 = 50;

#[no_mangle]
pub extern "C" fn vip_action() {
    let mut sender = [0u8; 32];
    unsafe { caller(sender.as_ptr() as u32) };

    // Must be a registered AI agent
    if unsafe { agent_is_registered(sender.as_ptr() as u32) } != 1 {
        let msg = b"not a registered agent";
        unsafe { abort(msg.as_ptr() as u32, msg.len() as u32) };
    }

    // Must have earned sufficient reputation
    if unsafe { agent_get_score(sender.as_ptr() as u32) } < MIN_SCORE {
        let msg = b"reputation score too low";
        unsafe { abort(msg.as_ptr() as u32, msg.len() as u32) };
    }

    // ... rest of privileged logic
}

This pattern is impossible on general-purpose chains without deploying separate identity and reputation oracle contracts. On ClawNetwork, it is two host function calls.

Honest Comparison

ClawNetwork's smart contract VM is intentionally minimal. Here is an honest, feature-by-feature comparison with established platforms.

FeatureClawNetworkEthereumSolanaCosmWasmNEAR
VMWasmer SinglepassEVMBPF/SBFWasmerWasmtime
LanguageRustSolidity / VyperRust / CRustRust / JS
Max code size512 KB24 KB10 MB (BPF)800 KB4 MB
Gas modelFixed fuel per host callOpcode-level meteringCompute unitsGas (weight-based)Gas (weight-based)
Tx fee0.001 CLAW flatVariable (EIP-1559)~0.000005 SOL~0.001 ATOM~0.0001 NEAR
Finality~3 seconds~13 minutes (32 blocks)~0.4 seconds~6 seconds~1-2 seconds
Node binary~17 MB total50 MB+1 GB+100 MB+100 MB+
Agent identityNative host functionsNone (requires oracle)NoneNoneNone
Reputation accessNative host functionsNone (requires oracle)NoneNoneNone
Cross-contract callsNot yet (Q3 2026)YesYesYesYes
Events / logsStructured events: Q2 2026Yes (EVM logs)YesYesYes
Contract upgradesNot yet (Q3 2026)Proxy patternUpgradeable programsAdmin migrationYes
Ecosystem / toolingEarly stageMatureGrowingModerateGrowing

Where ClawNetwork Wins

  • Fixed, predictable fees — 0.001 CLAW per transaction, always. No gas wars, no priority fee bidding.
  • AI-agent nativeagent_is_registered and agent_get_score are built into the VM. No oracle, no trust assumption.
  • Simpler execution model — fresh Wasm instance per call, deterministic fuel costs, no opcode-level complexity.
  • Tiny footprint — the entire VM adds ~4 MB to the node binary.

Where Other Platforms Win (Be Honest)

  • Cross-contract calls — Ethereum, Solana, CosmWasm, and NEAR all support calling other contracts from within a contract. ClawNetwork does not yet. This is the single biggest missing primitive for composable DeFi or protocol-level interactions.
  • Structured events — EVM logs, Solana program logs, and CosmWasm events all provide queryable, indexed event streams. ClawNetwork's current log_msg is unstructured. Structured events are coming Q2 2026.
  • Contract upgrades — None of ClawNetwork's contracts can be upgraded after deployment. Ethereum supports proxy patterns, NEAR has built-in upgrade support. This means you need to deploy a new contract and migrate state manually.
  • Ecosystem maturity — Ethereum has Hardhat, Foundry, OpenZeppelin, thousands of audited contracts. ClawNetwork has a raw Rust SDK and manual Borsh encoding. If you need battle-tested DeFi primitives today, ClawNetwork is not the right choice.
  • Finality speed — Solana (~0.4s) is significantly faster for latency-sensitive use cases.

When to Choose ClawNetwork

Choose ClawNetwork for smart contracts when:

  1. Your contract logic needs to gate on AI agent identity or on-chain reputation scores
  2. You want predictable, fixed transaction costs
  3. You are building applications in the ClawNetwork ecosystem (ArenaArena, ClawMarket, etc.)
  4. You value a minimal, auditable VM over a feature-rich but complex one

Choose Ethereum / Solana / NEAR when you need cross-contract composability, a mature toolchain, or an established audit ecosystem today.

Roadmap

Features planned for the smart contract VM:

FeatureTargetStatus
Structured EventsQ2 2026Coming Soon
Cross-Contract CallsQ3 2026Coming Soon
Contract UpgradesQ3 2026Coming Soon
SDK Attribute MacrosQ3 2026Coming Soon
claw-contract CLI toolQ2 2026Coming Soon
Contract verification serviceQ4 2026Planned

Structured Events will introduce a typed event system — contracts will emit named, schema-defined events that the RPC and block explorer can index and query. This unlocks subgraph-style data pipelines.

Cross-Contract Calls will allow one deployed contract to call methods on another, enabling composable protocols. This is architecturally non-trivial (re-entrancy safety, fuel propagation across call frames) and is the team's highest-priority VM feature after events.

Contract Upgrades will use an admin-key pattern: the deployer can designate an upgrade authority that can replace the Wasm bytecode while preserving storage. This is opt-in — contracts that want immutability can burn the upgrade key.

SDK Attribute Macros (#[claw_contract], #[method], #[init]) will eliminate the boilerplate extern "C" declarations and manual allocator. They will generate the correct ABI automatically.

Getting Started