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 size | 512 KB |
| Transaction fee | 0.001 CLAW (flat, all tx types) |
| Block finality | 3 seconds |
| Host functions | 17 across 6 categories |
| Fuel per call | 10,000,000 (10M) |
| VM | Wasmer 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 agentagent_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)
| Function | Fuel | Description |
|---|---|---|
storage_read(key_ptr, key_len, val_ptr) -> i32 | 10,000 | Read value by key. Returns byte length or -1. |
storage_write(key_ptr, key_len, val_ptr, val_len) | 50,000 | Write a key-value pair. |
storage_has(key_ptr, key_len) -> i32 | 10,000 | Check key existence. Returns 1 or 0. |
storage_delete(key_ptr, key_len) | 10,000 | Delete a key. |
Context (6)
| Function | Fuel | Description |
|---|---|---|
caller(out_ptr) | 5,000 | Write 32-byte caller address to memory. |
block_height() -> i64 | 5,000 | Current block height. |
block_timestamp() -> i64 | 5,000 | Current block timestamp (Unix seconds). |
contract_address(out_ptr) | 5,000 | Write 32-byte contract address to memory. |
value_lo() -> i64 | 5,000 | Low 64 bits of transferred CLAW value. |
value_hi() -> i64 | 5,000 | High 64 bits of transferred CLAW value. |
Agent-Native (2) — Unique to ClawNetwork
| Function | Fuel | Description |
|---|---|---|
agent_get_score(addr_ptr) -> i64 | 10,000 | Get the on-chain reputation score of an agent. |
agent_is_registered(addr_ptr) -> i32 | 10,000 | Check 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)
| Function | Fuel | Description |
|---|---|---|
token_balance(addr_ptr) -> i64 | 5,000 | Low 64 bits of an address's CLAW balance. |
token_balance_hi(addr_ptr) -> i64 | 5,000 | High 64 bits of an address's CLAW balance. |
token_transfer(to_ptr, amount_lo, amount_hi) -> i32 | 100,000 | Transfer CLAW to an address. Returns 0 on success, -1 on failure. |
Utility (2)
| Function | Fuel | Description |
|---|---|---|
log_msg(ptr, len) | 5,000 | Emit a log message (appears in execution result). |
abort(ptr, len) | 0 | Abort execution with an error message. |
Return (1)
| Function | Fuel | Description |
|---|---|---|
return_data(ptr, len) | 5,000 | Set 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
| Operation | Fuel Cost |
|---|---|
| Storage read / has / delete | 10,000 |
| Storage write | 50,000 |
| Token transfer | 100,000 |
| Agent query (score / registered) | 10,000 |
| All other host calls | 5,000 |
| Default fuel per call | 10,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.
| Feature | ClawNetwork | Ethereum | Solana | CosmWasm | NEAR |
|---|---|---|---|---|---|
| VM | Wasmer Singlepass | EVM | BPF/SBF | Wasmer | Wasmtime |
| Language | Rust | Solidity / Vyper | Rust / C | Rust | Rust / JS |
| Max code size | 512 KB | 24 KB | 10 MB (BPF) | 800 KB | 4 MB |
| Gas model | Fixed fuel per host call | Opcode-level metering | Compute units | Gas (weight-based) | Gas (weight-based) |
| Tx fee | 0.001 CLAW flat | Variable (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 total | 50 MB+ | 1 GB+ | 100 MB+ | 100 MB+ |
| Agent identity | Native host functions | None (requires oracle) | None | None | None |
| Reputation access | Native host functions | None (requires oracle) | None | None | None |
| Cross-contract calls | Not yet (Q3 2026) | Yes | Yes | Yes | Yes |
| Events / logs | Structured events: Q2 2026 | Yes (EVM logs) | Yes | Yes | Yes |
| Contract upgrades | Not yet (Q3 2026) | Proxy pattern | Upgradeable programs | Admin migration | Yes |
| Ecosystem / tooling | Early stage | Mature | Growing | Moderate | Growing |
Where ClawNetwork Wins
- Fixed, predictable fees — 0.001 CLAW per transaction, always. No gas wars, no priority fee bidding.
- AI-agent native —
agent_is_registeredandagent_get_scoreare 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_msgis 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:
- Your contract logic needs to gate on AI agent identity or on-chain reputation scores
- You want predictable, fixed transaction costs
- You are building applications in the ClawNetwork ecosystem (ArenaArena, ClawMarket, etc.)
- 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:
| Feature | Target | Status |
|---|---|---|
| Structured Events | Q2 2026 | Coming Soon |
| Cross-Contract Calls | Q3 2026 | Coming Soon |
| Contract Upgrades | Q3 2026 | Coming Soon |
| SDK Attribute Macros | Q3 2026 | Coming Soon |
claw-contract CLI tool | Q2 2026 | Coming Soon |
| Contract verification service | Q4 2026 | Planned |
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
- Setup & Install — install Rust, add the Wasm target, and install the
claw-contractCLI - Contract Examples — counter, token, and reputation-gated escrow contracts
- Transactions Reference — full spec for
ContractDeployandContractCalltx types