29. Building on Kortana (Quorlin)
Quorlin is Kortana's purpose-built, capability-secure programming language that compiles directly into 32-register KVM bytecode, offering compile-time exploit prevention.
29.1 Installing quorlinc
The quorlinc compiler is distributed alongside the core kortana-node software package. Built in modern C++23, quorlinc is a standalone, dependency-free binary that performs lexical analysis, parsing, type checking, semantic capability validation, and direct KVM bytecode generation.
Developers building kortana-node from source will find quorlinc generated in the build/quorlin/ directory. Alternatively, pre-compiled standalone binary releases for Linux and macOS can be installed directly into /usr/local/bin/ for system-wide command-line access.
29.2 Writing Your First Quorlin Contract
Quorlin smart contracts enforce capability-based security by requiring every function to announce its intended state effects (reads or writes) before its name. The language uses strong typing, checked 256-bit arithmetic, and explicit keywords for transaction context:
contract HelloKortana { text greeting; constructor { greeting = "Hello, World!"; } reads text getGreeting() { return greeting; } writes truth setGreeting(text newGreeting) { greeting = newGreeting; return yes; } }
The compiler guarantees that reads functions cannot execute storage write instructions or call external state-mutating methods, eliminating reentrancy vulnerabilities at compile time.
29.3 Deploying Quorlin Contracts
Deploying a Quorlin contract involves compiling the source code with quorlinc and broadcasting the compiled .kvm module using kortana-cli:
# Compile Quorlin contract to KVM module and ABI definition quorlinc HelloKortana.ql -o build/ # Broadcast deployment transaction to the network kortana-cli tx deploy \ --code build/HelloKortana.kvm \ --key deployer.key \ --rpc https://poseidon-rpc.testnet.kortana.xyz/
The node's Execution Router verifies the 4B 56 4D 00 ("KVM\0") magic prefix, executes the module's constructor logic, and commits the module directly to the state trie at the derived contract address.
29.4 Calling Quorlin from Solidity (and vice versa)
Kortana's Execution Router enables transparent, bidirectional interoperability between Solidity (KEVM) and Quorlin (KVM) contracts. A Solidity contract can call a Quorlin contract using standard ABI interfaces:
When a Solidity contract invokes IQuorlinToken(quorlinAddr).balanceOf(user), the EVM host halts execution, passes the calldata to the Execution Router, the router invokes the KVM interpreter, and the returned 256-bit value is placed into the EVM caller's memory. Both virtual machines share the identical gas meter and state trie, ensuring atomic cross-VM state transitions.
29.5 Standard Library Usage
The Quorlin standard library (quorlin/std/) provides verified, highly optimized reference implementations of core smart contract interfaces:
ERC20.ql: Full implementation of the standard fungible token specification with checked arithmetic.ERC721.ql: Non-fungible token (NFT) standard with safe transfer semantics and metadata tracking.Access.ql: Role-based access control and owner management modules.
Developers can import standard library contracts into their projects using standard import directives during compilation.