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

      2.11 Rock, Paper, Scissors in Python

    3 Guide

      3.1 Using Reach on Windows

      3.2 How does Reach use version numbers?

      3.3 How does Reach development compare to Solidity development?

        3.3.1 Solidity Development

        3.3.2 Reach Development

        3.3.3 Conclusion

      3.4 Do I have to use JavaScript to write my frontend? What about Python, Go, or other languages?

      3.5 How and what to verify

      3.6 Finding and using loop invariants

      3.7 Choosing a deployment mode

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

      3.9 Determinism, simultaneity, and choice in decentralized applications

      3.10 Racing non-determinism in decentralized applications

      3.11 Building decentralized abstractions

      3.12 Testing Reach programs in the browser

        3.12.1 Algorand

          3.12.1.1 Algorand: mnemonic

          3.12.1.2 Algorand: AlgoSigner

      3.13 What are Reach’s limitations and its future roadmap

      3.14 How does Reach work?

      3.15 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: Atomic Swap

      4.16 Workshop: Atomic Swap Auction

      4.17 Workshop: Race

      4.18 Workshop: Chicken

      4.19 Workshop: Popularity Contest

      4.20 Workshop: Simple NFT

      4.21 Workshop: NFT with Auction

      4.22 Workshop: NFT with Royalties and Harberger Tax

      4.23 Workshop: Raffle

      4.24 Workshop: Rent Seeking

      4.25 Workshop: Remote Objects

      4.26 Workshop: Oracle

      4.27 Workshop: Timed English Auction

      4.28 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 down

        5.2.5 reach scaffold

        5.2.6 reach react

        5.2.7 reach devnet

        5.2.8 reach rpc-server

        5.2.9 reach rpc-run

        5.2.10 reach docker-reset

        5.2.11 reach upgrade

        5.2.12 reach update

        5.2.13 reach version

        5.2.14 reach hashes

      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.2.2.2 Application Arguments

        5.4.3 Steps

          5.4.3.1 Statements

            5.4.3.1.1 only and each

            5.4.3.1.2 Pay Amounts

            5.4.3.1.3 publish, pay, when, and timeout

            5.4.3.1.4 fork

            5.4.3.1.5 wait

            5.4.3.1.6 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 fail

            5.4.4.2.5 declassify

            5.4.4.2.6 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 View Objects

            5.4.5.1.4 Participant.set and .set

            5.4.5.1.5 while

            5.4.5.1.6 continue

            5.4.5.1.7 parallelReduce

          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.5.2.5 Remote objects

            5.4.5.2.6 Mappings: creation and modification

            5.4.5.2.7 Sets: creation and modification

        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 Try/Catch & Throw Statements

            5.4.6.3.7 Expression statements

          5.4.6.4 Expressions

            5.4.6.4.1 ’use strict’

            5.4.6.4.2 Identifier reference

            5.4.6.4.3 Function application

            5.4.6.4.4 Types

            5.4.6.4.5 Literal values

            5.4.6.4.6 Operator expression

            5.4.6.4.7 xor

            5.4.6.4.8 Parenthesized expression

            5.4.6.4.9 Tuples

            5.4.6.4.10 array

            5.4.6.4.11 Element reference

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

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

            5.4.6.4.14 Foldable operations

            5.4.6.4.15 Array group operations

            5.4.6.4.16 Mapping group operations

            5.4.6.4.17 Objects

            5.4.6.4.18 Structs

            5.4.6.4.19 Field reference

            5.4.6.4.20 Object.set

            5.4.6.4.21 Object.setIfUnset

            5.4.6.4.22 Object.has

            5.4.6.4.23 Data

            5.4.6.4.24 Maybe

            5.4.6.4.25 Either

            5.4.6.4.26 match

            5.4.6.4.27 Conditional expression

            5.4.6.4.28 Arrow expression

            5.4.6.4.29 makeEnum

            5.4.6.4.30 assert

            5.4.6.4.31 forall

            5.4.6.4.32 possible

            5.4.6.4.33 digest

            5.4.6.4.34 balance

            5.4.6.4.35 lastConsensusTime

            5.4.6.4.36 makeDeadline

            5.4.6.4.37 implies

            5.4.6.4.38 ensure

            5.4.6.4.39 hasRandom

            5.4.6.4.40 compose

            5.4.6.4.41 sqrt

            5.4.6.4.42 pow

            5.4.6.4.43 Signed Integers

            5.4.6.4.44 Fixed-Point Numbers

            5.4.6.4.45 Anybody

            5.4.6.4.46 Intervals

      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.2 Reach RPC Server

          5.6.2.1 Reach RPC Client Standard Options

          5.6.2.2 Reach RPC Protocol Specification

          5.6.2.3 Reach RPC Protocol Client Implementation Walkthrough

      5.7 Frontend Support

        5.7.1 JavaScript

          5.7.1.1 Types

          5.7.1.2 loader.mjs

          5.7.1.3 Accounts

            5.7.1.3.1 Ethereum-specific

          5.7.1.4 Contracts

          5.7.1.5 Network Utilities

          5.7.1.6 Provider Selection

          5.7.1.7 Utilities

          5.7.1.8 ask.mjs

        5.7.2 JavaScript (RPC)

        5.7.3 Python (RPC)

        5.7.4 Go (RPC)

    Index