ErgoScript is a rich smart-contract language based on scala that supports Multi-Stage Contracts.
As a simple example, the below script allows only Alice to spend a box before a certain height and only Bob to spend the box after that.
if (HEIGHT < 100000) alicePubKey else bobPubKey
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.
Please see this Quick Primer on ErgoScript for an overview of key concepts and some basic examples.
Tutorials & Guides
- Learn ErgoScript By Example Via The Ergo Playground with Robert Kornacki (Video)
- ErgoScript by Example Repository
- Advanced ErgoScript Tutorial
- ErgoScript tutorial
- 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
A transaction to this P2S or pay-to-script address will create an output locked with the script
- You can do some simple apps with just the node and ErgoScript to P2S address compiler available at wallet.plutomonkey.com/p2s/, video tutorial
- 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 tx, 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.
The idea of proxy contracts came to life with the Ergo Assembler which helped dApp developments like Ergo Auction House, ErgoUtils, and SigmaUSD web interface despite not having a wallet-bridge like MetaMask (Ethereum wallet) in the ecosystem.
During this time, the structure of proxy contracts evolved as some malicious users tried to take advantage of some minor vulnerabilities, mostly in the SigmaUSD dApp.
Generally, you should ensure your proxy contracts
- Prevent dApp developers or any other attacker from taking advantage of user's funds in any manner
- Preserve the integrity of the dApp by preventing attacks like the ones explained in the above examples.
For more information please see EIP-0017