Learn ErgoScript by reading example smart contracts powered by the Ergo Playground.
Each contract example includes a Ergo Playground
link which allows you to instantly edit and run the smart contract code inside of your browser.
If you ever need clarity about how specific types/functions/operators in ErgoScript work, please reference the ErgoScript Language Description.
For an overarching summary of how everything in this repo works, please reference the video below:
Number | Difficulty | Title |
---|---|---|
1 | Beginner | Pin Lock Contract |
2 | Intermediate | Single-Chain Swap Contracts |
3 | Starter | Simple Send |
4 | Intermediate | Double-Chain Swap Contracts |
5 | Beginner | Timed Fund Contract |
6 | Beginner | Grantor/Beneficiary Pin Lock Contract |
7 | Beginner | Escrow Deposit Contract |
8 | Expert | Token sales service contract |
If you are unfamiliar with the Extended UTXO model, smart contracts, or Ergo specifically, the above examples may be a little bit challenging to jump straight into. As such the following links below are recommended resources for getting a solid background in understanding what is going on:
-
Emurgo Research: How Do UTXO Contracts Work? (First 2 sections)
-
Emurgo Research: High Level Design Patterns In EUTXO Systems
The first two links should enlighten you to the majority of the basics, and the links thereafter are more advanced deep dives.
We are always happy to include new community-submitted examples within this repo if you are interested in contributing.
All examples submitted must:
- Use the
Ergo Playground
via Scastie (basic template here) - Create a test scenario to show off the off-chain logic required for the contract to work
- Provide clear comments inside of the code explaining what is going on
- Follow the example template. (Ensure you include your scastie Ergo Playground url in both links)
- Have an understandable/relevant title + filename
Simply create a PR with your new exampleTitle.md
file added to the repo + this README.md
updated with your example added to the list of ErgoScript Examples.
If you are unsure about anything feel free to reference the first example contract and/or join the Ergo Discord to ask questions.