Tondi VMSmart contract execution

Tondi VM runs smart contracts: programs that define asset and application rules. Each run has resource limits, and the ledger verifies the result before recording changes.

Explore the steps

Milner + Tondi VM
From code to execution

Milner compiles contract rules into programs for Tondi VM. The VM runs them, and the ledger checks permissions and results before committing the related changes. The walkthrough below explains these steps; it does not compile code or send transactions.

gate.milMILNER

Example rule: allow an action only when its input meets the required condition.

Read the Milner code · for developers
validator gate(minimum: Int) {
  authorize(value: Int) {
    value >= minimum
  }
}
Download .mil source
  1. Code checks

    Types and IR
  2. RISC-V program

    ELF executable
  3. Tondi VM

    Metered execution
  4. Ledger checks

    Proposed changes

Write a contract in Milner. The example allows an action only when its input meets a condition.

Execution and validation rules

RISC-V instructions

RISC-V defines the instructions a program can use. Tondi specifies which instructions, data access and resource limits its contracts support.

A common validation path

Standard signature checks, custom permissions and application rules all run through the same system and have their work counted.

Consistent resource accounting

Running instructions, loading code and reading or copying data all count as work. Reusing cached data can save time, but it does not change the amount the protocol charges.

Verify proposed changes

A program returns proposed changes, called Effects. Tondi still checks asset amounts, permissions and other required rules before recording them.

Limits for
each resource

Compute

Count the instructions run and the work needed to prepare them.

Data access

Limit which records can be read and how much data can be read or sent.

Storage

Account for data kept on the network separately from the cost of running a program.

Memory

Limit the memory available to each program run.

Program execution
test data

Review a shared-application test with separate measurements for computation and result validation. The data and test conditions are available to download.

Program work details · for developers
Work to calculate · cycles
3,681,256
Work to check · cycles
4,713,403
Change data · bytes
1,720
Shared records updated
2

These are program-execution measurements, not network speed or security results. Cycles are units of work used for billing, not seconds; bytes measure data size. The capture date says when this file was copied, not when the original test ran.

Snapshot captured:
Source file SHA-256
ade44d9372837c35710c05c826b028f5376bae3b345e68867281af737ac1b154
Source file
docs/SHARED_RUNTIME_BENCHMARK.json

The hash is a digital fingerprint for checking that you have the same file. It does not prove exactly which code version was used to run the original test.

Meet the Milner language

Explore Milner