ACADEMY

v2

MODULE 14

LESSON 1

Writing Qubic Smart Contracts

Qubic contracts are written in a restricted C++ environment called the Qubic Programming Interface (QPI).

Key facts:

Deterministic & Secure

No dynamic memory, no pointers, fixed-size types only (e.g. uint8, uint16).

Single source file

All contract logic is self-contained and compiled to run natively on every validator (“Computor”).

Persistent State

Static variables become the contract’s on-chain state — up to 1 GiB.

Public Entry Points

Only methods registered in REGISTER_USER_FUNCTIONS_AND_PROCEDURES are callable externally.

CLI & Testnet

External data enters Qubic through Oracle Machines. These are deterministic feeders of real-world information — essential for contracts needing off-chain data.

Every contract must be deployed to Qubic testnet before submission to mainnet. This ensures validator and community testing before quorum voting.

Example (copied directly from QPI example repo):

void REGISTER_USER_FUNCTIONS_AND_PROCEDURES() {
    REGISTER_FUNCTION(greet);
    REGISTER_PROCEDURE(setGreeting)

PRO TIP

When planning your storage, think long term. Large state increases storage fees each epoch.

HANDS-ON TASK

Set up the Qubic Dev Kit and open the demo contract. Identify every variable that persists across ticks. Label which ones you’d keep if you were writing a simple token.

HANDS-ON TASK

Set up the Qubic Dev Kit and open the demo contract. Identify every variable that persists across ticks. Label which ones you’d keep if you were writing a simple token.

PRO TIP

When planning your storage, think long term. Large state increases storage fees each epoch.

© 2025 Qubic.

Qubic is a decentralized, open-source network for experimental technology. Nothing on this site should be construed as investment, legal, or financial advice. Qubic does not offer securities, and participation in the network may involve risks. Users are responsible for complying with local regulations. Please consult legal and financial professionals before engaging with the platform.

© 2025 Qubic.

Qubic is a decentralized, open-source network for experimental technology. Nothing on this site should be construed as investment, legal, or financial advice. Qubic does not offer securities, and participation in the network may involve risks. Users are responsible for complying with local regulations. Please consult legal and financial professionals before engaging with the platform.