On this page:
Reach:   The Safest and Easiest DApp Programming Language
0.1.2

Reach: The Safest and Easiest DApp Programming Language

Jay McCarthy <jay@reach.sh>

Reach is a domain-specific language for building decentralized applications (DApps).

This set of documents contains everything you need to know about Reach.

If you are looking for something specific, here are some places to look:

The source of this site is available on GitHub; we welcome Pull Requests for improvements and Issues for problem reports!

    1 Overview

      1.1 Decentralized applications

      1.2 A minimal Reach program

      1.3 Compile

      1.4 Verify

      1.5 Interface

      1.6 Execute

      1.7 Web app

      1.8 Next steps

    2 Tutorial

      2.1 Install and Initialize

      2.2 Scaffolding and Setup

      2.3 Rock, Paper, and Scissors

      2.4 Bets and Wagers

      2.5 Trust and Commitments

      2.6 Timeouts and Participation

      2.7 Play and Play Again

      2.8 Interaction and Independence

      2.9 Web Interaction

      2.10 Onward and Further

    3 Guide

      3.1 Using Reach on Windows

      3.2 How does Reach use version numbers?

      3.3 How and what to verify

      3.4 Finding and using loop invariants

      3.5 Choosing a deployment mode

      3.6 Non-participation: What it is and how to protect against it

      3.7 Determinism, simultaneity, and choice in decentralized applications

      3.8 Racing non-determinism in decentralized applications

      3.9 Building decentralized abstractions

      3.10 What are Reach’s limitations and its future roadmap

      3.11 How does Reach work?

      3.12 IDE/Text Editor Support

    4 Workshop

      4.1 Workshop: Hash Lock

        4.1.1 Problem Analysis

        4.1.2 Data Definition

        4.1.3 Communication Construction

        4.1.4 Assertion Insertion

        4.1.5 Interaction Introduction

        4.1.6 Deployment Decisions

        4.1.7 Discussion

      4.2 Workshop: Relay Account

        4.2.1 Problem Analysis

        4.2.2 Data Definition

        4.2.3 Communication Construction

        4.2.4 Assertion Insertion

        4.2.5 Interaction Introduction

        4.2.6 Deployment Decisions

        4.2.7 Discussion and Next Steps

      4.3 Workshop: Trust Fund

        4.3.1 Problem Analysis

        4.3.2 Data Definition

        4.3.3 Communication Construction

        4.3.4 Assertion Insertion

        4.3.5 Interaction Introduction

        4.3.6 Deployment Decisions

        4.3.7 Discussion and Next Steps

      4.4 Workshop: Fear of Missing Out

        4.4.1 Problem Analysis

        4.4.2 Data Definition

        4.4.3 Communication Construction

        4.4.4 Assertion Insertion

        4.4.5 Interaction Introduction

        4.4.6 Deployment Decisions

        4.4.7 Discussion and Next Steps

      4.5 Workshop: Fear of Missing Out Generalized

        4.5.1 Problem Analysis

        4.5.2 Data Definition

        4.5.3 Communication Construction

        4.5.4 Assertion Insertion

        4.5.5 Interaction Introduction

        4.5.6 Deployment Decisions

        4.5.7 Discussion and Next Steps

      4.6 Workshop: Fair Rock-Paper-Scissors

      4.7 Workshop: Efficient Rock-Paper-Scissors

      4.8 Workshop: Rental Agreement

      4.9 Workshop: Simultaneous Games

      4.10 Workshop: Guardian Account

      4.11 Workshop: Periodic Payment

      4.12 Workshop: Nim

      4.13 Workshop: Tic-Tac-Toe

      4.14 Workshop: Secured Loan

      4.15 Workshop: Oracle

      4.16 Workshop: Race

      4.17 Workshop: Chicken

      4.18 Workshop: Popularity Contest

      4.19 Workshop: Timed English Auction

      4.20 Workshop: Crowd-funding

    5 Reference

      5.1 Installation

      5.2 Usage

        5.2.1 reach compile

        5.2.2 reach init

        5.2.3 reach run

        5.2.4 reach scaffold

        5.2.5 reach upgrade

        5.2.6 reach update

        5.2.7 reach version

      5.3 Language Model

        5.3.1 Evaluation Model

        5.3.2 Compilation Model

        5.3.3 Syntax Model

      5.4 Programs

        5.4.1 Validity

          5.4.1.1 Security levels and scope

        5.4.2 Modules

          5.4.2.1 Statements

            5.4.2.1.1 export

            5.4.2.1.2 import

          5.4.2.2 Expressions

            5.4.2.2.1 Reach.App

        5.4.3 Steps

          5.4.3.1 Statements

            5.4.3.1.1 only and each

            5.4.3.1.2 publish, pay, when, and timeout

            5.4.3.1.3 fork

            5.4.3.1.4 wait

            5.4.3.1.5 exit

          5.4.3.2 Expressions

            5.4.3.2.1 race

            5.4.3.2.2 unknowable

            5.4.3.2.3 closeTo

        5.4.4 Local Steps

          5.4.4.1 Statements

          5.4.4.2 Expressions

            5.4.4.2.1 this

            5.4.4.2.2 interact

            5.4.4.2.3 assume

            5.4.4.2.4 declassify

            5.4.4.2.5 makeCommitment

        5.4.5 Consensus Steps

          5.4.5.1 Statements

            5.4.5.1.1 commit

            5.4.5.1.2 only and each

            5.4.5.1.3 Participant.set and .set

            5.4.5.1.4 while

            5.4.5.1.5 continue

            5.4.5.1.6 parallel_reduce

          5.4.5.2 Expressions

            5.4.5.2.1 this

            5.4.5.2.2 transfer

            5.4.5.2.3 require

            5.4.5.2.4 checkCommitment

        5.4.6 Computations

          5.4.6.1 Comments

          5.4.6.2 Blocks

          5.4.6.3 Statements

            5.4.6.3.1 const and function

            5.4.6.3.2 return

            5.4.6.3.3 if

            5.4.6.3.4 switch

            5.4.6.3.5 Block statements

            5.4.6.3.6 Expression statements

          5.4.6.4 Expressions

            5.4.6.4.1 Identifier reference

            5.4.6.4.2 Function application

            5.4.6.4.3 Types

            5.4.6.4.4 Literal values

            5.4.6.4.5 Operator expression

            5.4.6.4.6 Parenthesized expression

            5.4.6.4.7 Tuples

            5.4.6.4.8 array

            5.4.6.4.9 Element reference

            5.4.6.4.10 Array & tuple length: Tuple.length, Array.length, and .length

            5.4.6.4.11 Array & tuple update: Tuple.set, Array.set, and .set

            5.4.6.4.12 Array group operations

            5.4.6.4.13 Objects

            5.4.6.4.14 Field reference

            5.4.6.4.15 Object.set

            5.4.6.4.16 Object.setIfUnset

            5.4.6.4.17 Object.has

            5.4.6.4.18 Data

            5.4.6.4.19 Maybe

            5.4.6.4.20 Either

            5.4.6.4.21 match

            5.4.6.4.22 Conditional expression

            5.4.6.4.23 Arrow expression

            5.4.6.4.24 makeEnum

            5.4.6.4.25 assert

            5.4.6.4.26 forall

            5.4.6.4.27 possible

            5.4.6.4.28 digest

            5.4.6.4.29 balance

            5.4.6.4.30 lastConsensusTime

            5.4.6.4.31 implies

            5.4.6.4.32 ensure

            5.4.6.4.33 hasRandom

      5.5 Consensus Network Connectors

        5.5.1 Ethereum

        5.5.2 Algorand

      5.6 Participant Backends

        5.6.1 JavaScript

          5.6.1.1 Guarantees

          5.6.1.2 loader.mjs

          5.6.1.3 Standard Library

            5.6.1.3.1 Utilities

          5.6.1.4 ask.mjs

    Index