29. Building on Kortana (Quorlin)
Quorlin is Kortana’s native, capability-secure language targeting the custom KVM. It prevents entire classes of vulnerabilities (like reentrancy and unauthorized state mutation) by strictly separating reads and writes.
29.1 Installing quorlinc
The Quorlin compiler, quorlinc, is shipped alongside the kortana-node binary. It takes a .ql file and outputs a compiled .kvm module along with a standard Ethereum ABI JSON file.
29.2 Writing Your First Quorlin Contract
A Quorlin contract defines state, events, and functions. Note that function effects are declared before the function name.
contract HelloKortana { text greeting; constructor { greeting = "Hello, World!"; } reads text getGreeting() { return greeting; } writes truth setGreeting(text newGreeting) { greeting = newGreeting; return yes; } }
29.3 Deploying Quorlin Contracts
Deploy Quorlin contracts using the Kortana CLI, which handles the 4B564D00 magic prefix wrapping automatically.
quorlinc HelloKortana.ql -o build/ kortana-cli tx deploy --code build/HelloKortana.kvm --key deployer.key
29.4 Calling Quorlin from Solidity (and vice versa)
Because both the KEVM and KVM sit below the Execution Router and share a state trie, interoperability is seamless.
- Solidity to Quorlin: Compile the Quorlin contract to generate the ABI JSON. In your Solidity project, create a standard
interfacematching that ABI. When your Solidity contract makes anexternalcall to the Quorlin address, the router forwards it to the KVM automatically. - Quorlin to Solidity: Declare the Solidity contract's signature as an
interfacein your Quorlin file.
29.5 Standard Library Usage
Quorlin provides deeply audited standard library implementations:
ERC20.ql: Fully compatible with the ERC-20 standard.ERC721.ql: Fully compatible with the ERC-721 standard.Access.ql: Role-based access control.