Learning Ergo 101 : eUTXO explained for human beings

Blockchain Paradigms

Let’s step back a bit first. Consider programming: There are different paradigms for programming: Functional Programming, Object Oriented..among others.
A programming language usually implements one of these paradigms or a combination of them. These paradigms affect how you consider solving problems.

  1. Account based

eUTXO (extended Unspent Transactions Output)

Let’s first conceptualise how the Ergo blockchain looks like for someone who is building solutions on top of it.

  • Consider the Ergo blockchain as a Dataset of Boxes.
  • Each Box contains assets: Cryptocurrency (Either ERG and/or other tokens)
Ergo blockchain is a collection of Boxes
  • As a user of the Ergo blockchain you can interact with some of those boxes.
  • Applications built on top of Ergo work by using existing boxes and creating new boxes
  • Each Box contains crypto assets (namely Erg or other coins)
An Ergo Box
Each box contains some crypto assets

Transactions

Imagine a transaction as a programming function that is already defined. You can use this function and it looks like as in the illustration below:

A transaction : Operation we can apply on existing unspent boxes

The Script field

Remember that boxes contain a field called script ?

  • Each box has a script.
  • A script is a chunk of logic which evaluates to a boolean value: True or False.
  • At transaction time the script of the input boxes is evaluated.
    If the evaluation returns true then your transaction is successful and the output boxes are created.
  • In the ergo blockchain the programming language you can use to define the script field is called ErgoScript.
  • ErgoScript is on purpose quite limited
  • Because ErgoScript is very constrained the Ergo blockchain can know in advance the cost of executing that script. This might not be very relevant for this blog post , but this is a core differentiator from other blockchain systems. This is the reason why transaction costs in Ergo are fixed.
  • As a programmer you can define your own script and use them in your boxes.
  • By using the script field along side boxes and transactions you can model solutions to problems. This is the core of building DApps in Ergo and Cardano.
Assets associated to a wallet
  1. There are one or more unspent Boxes that in total contain 100ERG
  2. Those Boxes’ script corresponds to the wallet’s public key (public address).
    This script is guarding the box such that If you want to use any of those boxes in a transaction, you need to provide a signed message proving you are the owner of the companion private key.
  3. When your wallet app wants to know your balance it scans the blockchain looking for unspent boxes whose script corresponds to your public wallet address.
Balance of a wallet

Final thoughts

The eUTXO model is very interesting . If you are familiar with Functional programming you can see how some concepts are similar. For example in eUTXO there is no mutability: You can’t mutate a box. You can only create new ones. Just as in functional Programming there is not a global state.
From my perspective, as an engineer, immutability and not global state makes things much simpler.

References and further reads :

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
David Przybilla

David Przybilla

Working on Recommendation Systems, NLP and Data Engineering🗼🇯🇵 @dav009