About
rust V8-based TypeScript execution engine

Tags
denorusttanatstypescriptv8blockchainsmartcontracts

Languages
Rust 94%, TypeScript 6%, JavaScript 0%

tana-runtime

V8-based TypeScript execution engine for Tana smart contracts.

overview

tana-runtime executes smart contract code in an isolated V8 sandbox. it provides the trusted execution environment where contract logic runs during block production, with access to Tana-specific modules for storage, context, and blockchain state.

how it works

when the ledger service needs to execute a contract, it invokes tana-runtime with the contract code and execution context. the runtime creates a fresh V8 isolate, loads the Tana module system, executes the contract function, and returns the results.

execution model

contract code (TypeScript)
         |
         v
    tana-runtime
         |
    +----+----+
    |         |
  V8 isolate  Tana modules
    |         (kv, context, block, tx)
    |         |
    +----+----+
         |
         v
   execution result
   (state changes, return value)

built-in modules

contracts can import from the Tana module system:

  • tana/kv - key-value storage operations
  • tana/context - execution context (caller, timestamp)
  • tana/block - current block information
  • tana/tx - transaction details
  • tana/core - utility functions

sandboxing

each contract execution runs in a fresh isolate with:

  • no filesystem access
  • no network access
  • deterministic execution
  • memory limits
  • execution timeouts

architecture

built with Rust using deno_core for V8 integration. the runtime compiles to a standalone binary that the ledger service invokes as a subprocess.

contract validation

before execution, the runtime validates contracts using AST analysis:

  • checks for forbidden imports
  • verifies export signatures
  • ensures deterministic patterns

validation errors include precise source locations and helpful suggestions, styled after Rust/Gleam compiler output.

integration

tana-runtime is bundled with the Tana CLI distribution as a platform-specific binary. the ledger service manages runtime invocation during block production.