- Ergo is a UTXO based blockchain with Proof-of-Work consensus
- Ergo is considered an extended-UTXO model, supporting advanced financial contracts similar to those in Ethereum's account-based model
- Since Ergo is UTXO based, therefore ErgoScript has many UTXO-specific constructs such as:
- A complete list is available here
Boxis 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
INPUTSarray), and creates one or more new boxes (denoted using the
- 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.
- 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 the
- Unlike Scala, ErgoScript does not support the
varkeyword, and thus everything is immutable
- The scripting language in itself is non-Turing complete, but applications can be made to be Turing complete as demonstrated in this peer-reviewed paper.
if (HEIGHT < 100000) alicePubKey else bobPubKey
- Allows Only Alice to spend a box before a certain height
- Allows Only Bob to spend the box after that.
Please see this Quick Primer on ErgoScript for an overview of key concepts and some basic examples.
- Learn ErgoScript By Example Via The Ergo Playground with Robert Kornacki (Video)
- ErgoScript by Example Repository
- Testing Ergo Contracts Off-chain
- Deco Education: 2022 Script Class
- FlowCards | A Declarative Framework for Development of Ergo dApps (Also see flowcardLib)
- flowcardLib: Ergo FlowCard library for diagrams.net
- Compile ErgoScript directly in your browser with ErgoScript Playground
- Kiosk lets anyone play with ErgoScript using a basic web-based UI
You can do some simple apps with just the node and ErgoScript to
P2S address compiler available at wallet.plutomonkey.com/p2s. A transaction to this P2S or pay-to-script address will create an output locked with the script
- Wrapped ERG can always be trustlessly exchanged 1:1 for native ERG.
- 3-out-of-5 Threshold Signature
Typically most people use P2S because it is a lot easier to use. P2SH means you have to keep the contract ready off-chain to be submitted when you create the transaction, and if you lose it, then your funds are stuck forever. This also makes it harder for other people to use your dApp as they need the contract themselves, rather than just the address. P2SH is technically cheaper since you store less data on-chain, but likely we won't see anyone using P2SH until we start to get heavy load on-chain.