Introduction
ErgoScript is Ergo’s dedicated smart contract language, based on Scala and designed from the ground up for the Ergo blockchain. While EVM platforms primarily use Solidity, ErgoScript reflects the unique properties of the eUTXO model and focuses on secure, functional smart contracts.
Instead of mutating global account balances, ErgoScript enforces conditions for spending UTXOs – unspent transaction outputs, or “boxes” of coins. The result is a predictable, auditable, and strongly constrained environment for Ergo smart contracts and dApps.
In this 30-minute introduction you'll learn what ErgoScript is, how it works with the eUTXO model, see simple ErgoScript examples, and understand where it differs from Solidity, Bitcoin Script, and Cardano's Plutus.
What Is ErgoScript?
As the Ergo scripting language, ErgoScript takes a different approach compared to most mainstream smart contract platforms. Instead of orchestrating long-lived contracts with internal state, ErgoScript defines rules for spending individual boxes in the eUTXO model.
ErgoScript is functional, not imperative. Imperative languages like Solidity, Python, or JavaScript tell the computer what to do, step by step, updating variables and global state along the way. A Solidity contract can say, “Subtract 10 from this token balance,” changing an account balance in place.
Functional languages evaluate expressions and produce True/False results instead of mutating state. ErgoScript scripts don’t “run”; they validate. A simple condition might be “Check whether the amount being spent is less than 10.” The script just describes rules and lets the system decide whether a spend is allowed.
That means ErgoScript does not directly modify on-chain state. It simply answers: “Is this UTXO (box) allowed to be spent under these rules, in this context?”
There are no loops, no global memory, and no mutable variables. When a user tries to spend a box, the attached ErgoScript is evaluated. If the expression returns True, the spend is valid; if not, the transaction is rejected.
Visualising ErgoScript: A Lockbox With Rules
Imagine a physical lockbox full of coins. On the outside of the box you write the rules:
- Only Alice can open this box.
- The box can only be opened after 31 December 2025.
- Only 100 ERG can be removed per day.
ErgoScript is the language you use to encode these rules on-chain. Anyone can see and verify them before interacting with the box.
This box-centric, rule-driven design increases predictability for Ergo smart contracts, shrinks the possible attack surface, and simplifies security audits.
How ErgoScript Works
ErgoScript validates attempts to spend specific boxes. It doesn’t execute arbitrary instructions; it just checks whether a box may be spent in the context of a proposed transaction.
Every transaction on the Ergo blockchain includes:
- Inputs: existing UTXOs (boxes) to be spent
- Outputs: new UTXOs that will be created
- Context: environment data such as block height, transaction metadata, referenced data inputs, and more
When a transaction tries to spend a given box, the attached ErgoScript sees the box, the full transaction, and relevant context. If the conditions evaluate to True, the transaction is valid and can be included in a block.
This model is stateless and deterministic. Anyone can run the script locally against a candidate transaction and know exactly what the result will be before broadcasting. Even fee cost is predictable, since execution paths are well-bounded and there are no hidden loops.
Registers & Context
Each UTXO on the Ergo blockchain can hold up to 10 registers – tiny slots for data that make the eUTXO model far more expressive than Bitcoin’s simple UTXOs.
- R0, R1, R2: reserved for protocol use.
- R3–R9: available for arbitrary data such as oracle values, ZK proofs, previous state references, timelocks, or spending policy flags.
Because boxes are immutable, “updating state” simply means spending an old box and creating a new one with updated register