Skip to content

Learn ErgoScript by reading example smart contracts powered by Ergo Playground.

Notifications You must be signed in to change notification settings

realfakeprogrammer/ergoscript-by-example

 
 

Repository files navigation

ErgoScript By Example

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:

Table Of Contents

ErgoScript Examples

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
9 Beginner Self-Replicating Sale Contract
10 Intermediate Heads or Tails game Contract
11 Expert Stealth Address
12 Expert Heads or Tails game Contract with Parallelization

Extra Resources To Get Started

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:

  1. Emurgo Research: How Do UTXO Contracts Work? (First 2 sections)

  2. ErgoScript Whitepaper

  3. Advanced ErgoScript Whitepaper

  4. 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.

Other Resources

  • Video: Ergoscript examples using AppKit This video covers the lifecycle of a smart contract on ergo, how to interact with the blockchain. It also covers step by step some of the examples in this repository.

How To Contribute

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.

About

Learn ErgoScript by reading example smart contracts powered by Ergo Playground.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published