ErgoScript vs ErgoTree

Understanding the difference between high-level ErgoScript and low-level ErgoTree languages in the Ergo ecosystem.

Back to ErgoScript Languages

Language Overview

ErgoScript is a high-level, developer-friendly language for writing smart contracts that are then compiled to ErgoTree before being written to the blockchain.

The Ergo node does not understand ErgoScript. Instead, it uses a low-level language called ErgoTree, which is a "tree-based" language (somewhat like XML).

ErgoTree Complexity

However, writing code in ErgoTree is difficult.

  • ErgoTree is similar to Bitcoin's Script in some aspects.
  • An ErgoTree program is deterministic and consists of a sequence of boolean predicates joined using AND and OR.
  • Ergo nodes execute the ErgoTree program contained in a transaction and consider it valid if it evaluates to true.

Code Examples

ErgoTree Example

An example of such an ErgoTree program would be:

AND(OR(condition_1, condition_2), condition_3)

This implies that the transaction is valid if condition_3 holds and at least one of condition_1 or condition_2 holds.

ErgoScript Equivalent

The equivalent of the above program in ErgoScript would be:

(condition_1 || condition_2) && condition_3

Much more readable and familiar to developers coming from traditional programming languages!