ErgoScript Key Concepts#
- Ergo is a UTXO-based blockchain with Proof-of-Work consensus
- Ergo uses an extended-UTXO model, supporting advanced financial contracts comparable to those in Ethereum's account-based model.
- Since Ergo is UTXO-based, ErgoScript has many UTXO-specific constructs such as:
Box
,INPUTS
, andOUTPUTS
. A complete list is available here - A Box is essentially a UTXO and consists of up to ten registers for storing data. Similar to Bitcoin, a transaction spends one or more existing boxes (denoted using the
INPUTS
array) and creates one or more new boxes (denoted using theOUTPUTS
array) - ErgoScript's syntax is a subset of Scala's. However, knowledge of Scala is not necessary to learn ErgoScript because the amount of Scala needed to write ErgoScript is small, e.g.
val
- Note that arrays in Scala are accessed using round parentheses, not square brackets like in Java or Python. Thus,
OUTPUTS(0)
refers to the first element of theOUTPUTS
array - Unlike Scala, ErgoScript does not support the
var
keyword, and thus everything is immutable - The scripting language is non-Turing complete, but applications can be made to be Turing complete, as demonstrated in this peer-reviewed paper.
Key Concepts#
-
Since Ergo is UTXO based, ErgoScript has many UTXO-specific constructs such as
Box
,INPUTS
,OUTPUTS
, etc. A complete list is available here. A Box is essentially a UTXO and consists of up to ten registers for storing data. Similar to Bitcoin, a transaction spends one or more existing boxes (denoted using theINPUTS
array) and creates one or more new boxes (denoted using theOUTPUTS
array). -
ErgoScript's syntax is a subset of Scala's. However, knowledge of Scala is not necessary to learn ErgoScript because the amount of Scala needed to write ErgoScript is tiny. That being said, some prior experience in Scala will be useful in picking up ErgoScript and Scala is a good language to have on your resume anyway.
-
Like Scala, ErgoScript supports functional programming, which makes it easier to deal with collections using metaphors such as
foreach
,exists
,fold
, etc. -
Like ErgoTree, an ErgoScript program consists of a sequence of boolean predicates joined using
&&
and||
. -
ErgoScript provides cryptographic operations via
BigInt
andGroupElement
(Elliptic curve point) types along with relevant operations such as addition, multiplication and exponentiation. Note that, unlike Scala,BigInt
operations in ErgoScript are performed modulo2^256
, and thus, care must be taken about overflow.