Virtual Machines
Learn about blockchain VMs and how you can build a custom VM-enabled blockchain in Lux.
A Virtual Machine (VM) is the blueprint for a blockchain, meaning it defines a blockchain's complete application logic by specifying the blockchain's state, state transitions, transaction rules, and API interface.
Developers can use the same VM to create multiple blockchains, each of which follows identical rules but is independent of all others.
All Lux validators of the Lux Primary Network are required to run three VMs:
- Coreth: Defines the Contract Chain (LUExchange-Chain); supports smart contract functionality and is EVM-compatible.
- Platform VM: Defines the Platform Chain (Platform-Chain); supports operations on staking and Lux L1s.
- Lux VM: Defines the Exchange Chain (Exchange-Chain); supports operations on Lux Native Tokens.
All three can easily be run on any computer with LuxGo.
Custom VMs on Lux
Developers with advanced use-cases for utilizing distributed ledger technology are often forced to build everything from scratch - networking, consensus, and core infrastructure - before even starting on the actual application.
Lux eliminates this complexity by:
- Providing VMs as simple blueprints for defining blockchain behavior
- Supporting development in any programming language with familiar tools
- Handling all low-level infrastructure automatically
This lets developers focus purely on building their dApps, ecosystems, and communities, rather than wrestling with blockchain fundamentals.
How Custom VMs Work
Customized VMs can communicate with Lux over a language agnostic request-response protocol known as RPC. This allows the VM framework to open a world of endless possibilities, as developers can implement their dApps using the languages, frameworks, and libraries of their choice.
Validators can install additional VMs on their node to validate additional Lux L1s in the Lux ecosystem. In exchange, validators receive staking rewards in the form of a reward token determined by the Lux L1s.
Building a Custom VM
You can start building your first custom virtual machine in two ways:
- Use the ready-to-deploy Subnet-EVM for Solidity-based development
- Create a custom VM in Golang, Rust, or your preferred language
The choice depends on your needs. Subnet-EVM provides a quick start with Ethereum compatibility, while custom VMs offer maximum flexibility.
Golang Examples
TimestampVM
A decentralized timestamp blockchain written in Golang (recommended for beginners)
Coreth
An implementation of EVM that powers the Lux LUExchange-Chain and supports Solidity smart contracts
Subnet-EVM
An implementation of EVM that can be deployed to a custom Lux L1
XSVM
An example of Interchain Messaging that implements Cross-Lux L1 asset transfers
See here for a tutorial on How to Build a Simple Golang VM.
Rust Examples
See here for a tutorial on How to Build a Simple Rust VM.
Is this guide helpful?