Skip to content

DuskVM

DuskVM is the WASM virtual machine for smart contracts that execute directly on the Dusk L1. It is based on the Wasmtime runtime, with custom support for Dusk’s execution model.

Use DuskVM for Rust/WASM contracts, protocol-level assets, custom execution, market logic, privacy-aware flows, or zero-knowledge capabilities that should run directly on the L1.

Use DuskEVM instead when your application is designed around Solidity, EVM wallets, and Ethereum-compatible tooling. See DuskEVM.

DuskVM is the smart-contract execution component of the Dusk L1. DuskVM executes contract code, while DuskDS provides the consensus, settlement, and data-availability foundation that finalizes the resulting state.

At a high level, DuskVM provides:

  • Specific memory management mechanism
  • Support for Dusk’s ABI
  • Support for inter-contract calls

DuskVM functions as the host-side interface, handling the execution environment and system-level operations.

DuskVM expects WASM as bytecode, meaning that smart contracts must be compiled into WASM bytecode in order for DuskVM to execute them. Smart contracts are entirely responsible for validating their inputs, processing them according to the contract’s logic, and returning the appropriate outputs. This ensures that smart contracts operate predictably and securely within the standardized execution environment provided by DuskVM.

Contracts compiled to WASM can be executed by DuskVM, with the following caveats:

  • The contract needs to expose the “argument buffer” (argbuf), which is a special region of 64KB in the contract’s memory
  • Each exposed function complies with the following calling convention: fn foo(u32) -> u32

The received u32 value indicates the length of the input data, which has been placed in the argbuf by the caller. This input length specifies how many bytes of data the contract should read from the argbuf. After processing the input, the contract writes the output data back into the argbuf. The return u32 value then indicates the length of this output data, specifying how many bytes of data the contract has written to the argbuf. This mechanism ensures that both the input and output lengths are communicated, allowing the contract to properly handle the data within the defined buffer space.

Dusk Core provides contract-side types and ABI modules used to build DuskVM contracts.