Reach has a few sub-commands, each with their own options.
However, all commands support the following options:
The environment variable REACH_VERSION signifies what version of Reach to use.
You compile your Reach code by executing
$ reach compile SOURCE EXPORT ...
If no SOURCE is provided, then index.rsh is used.
If no EXPORT is provided, then all the exported Reach.Apps will be compiled. If there are no Reach.Apps exported, then the program will be compiled as a library, where its exports are available to other Reach programs and frontends. The output name of a library is the same as if it exported a Reach.App named default.
reach compile supports the following options:
-o/--output ‹OUTPUT› —
Writes compiler output files to ‹OUTPUT›, which defaults to a directory named build in the same directory as SOURCE.
Write intermediate files, which may be interesting for debugging compilation failures or using in other contexts.
Allows Reach to fetch remote package imports and stop after doing so.
Reach will fail with an error message if package imports have not yet been fetched and this flag is not activated.
Using this flag will create a .reach directory for your project. This directory stores your project’s lockfile, which is how Reach pins remote packages to specific versions. It is recommended that you commit the .reach directory to source control. Deleting this directory is also safe; it can easily be rebuilt by using the --install-pkgs flag again; in fact, this is the best way to upgrade your packages.
Stops the compilation process before verification and producing output files. This might be useful for performing syntax and type checking quickly.
--verify-timeout ‹TIMEOUT-MS› —
Sets the timeout of individual verification theorems, in milliseconds. The default value is 2 minutes.
The environment variable REACH_DEBUG, if set to any non-empty value, enables debug messages from the Reach compiler, which will appear in the console. This debug information includes: the estimated cost of the contract on Algorand.
You can create template index.rsh and index.mjs files for a simple Reach app by running
$ reach init
You can run a simple Reach application by executing
$ reach run [APP or DIR] [ARGS]
APP represents a Reach module name without its extension (e.g. "index" by default).
If no APP or DIR is provided then index in the current working directory is assumed.
If DIR matches an existing, relative subdirectory of the current working directory then DIR/index is used.
ARGS represents zero or more arguments to be passed into APP’s frontend.
Your Reach program is named APP.rsh.
Compiles your program with Reach.
Executes a container based upon that image while connected to the network determined by REACH_CONNECTOR_MODE.
reach run supports the following options:
The environment variable REACH_CONNECTOR_MODE specifies which context to run in. The default, if this variable is unset or empty, is ETH-devnet. The options are:
ETH-live, which uses a live Ethereum network node, specified by the environment variable ETH_NODE_URI.
ALGO-live, which uses a live Algorand network node, specified by the environment variables documented in the Algorand connector section.
reach run can be further specialized via the presence of a Dockerfile and package.json file. If either are absent, reach run assumes a default behavior (which may be persisted with reach scaffold).
The Dockerfile can be modified to introduce new dependencies, services, or filesystem prerequisites into your app’s containerized environment, and the package.json file may likewise be extended to include additional libraries or make configuration changes to the resultant Node.js package.
You can halt all Dockerized Reach apps and devnets by running
$ reach down
You can create templated Dockerfile and package.json files for a simple Reach app by running
$ reach scaffold
The files created are the same as those used temporarily by reach run.
You can run a simple React app by executing
$ reach react
Your Reach program is named index.rsh
Your frontend React program is named index.js
Compiles your program with Reach
Runs the appropriate devnet based on REACH_CONNECTOR_MODE
Mounts the current directory into /app/src/ in the reachsh/react-runner Docker image and runs it.
reach react supports the following options:
The environment variable REACH_CONNECTOR_MODE specifies which context to run in. The default, if this variable is unset or empty, is ETH. The options are:
ETH, which runs a Dockerized private Ethereum network which may be used. The app can use any Ethereum network.
ALGO, which runs a Dockerized private Algorand network which may be used. (Support for using any Algorand network is forthcoming with TEAL 3.)
The environment variable REACH_DEBUG, if set to any non-empty value, enables debug messages from the Reach standard library, which will appear in the browser console.
You can run a private Reach devnet by executing
$ reach devnet
reach devnet supports the following options:
Run in background and await availability.
The environment variable REACH_CONNECTOR_MODE specifies which devnet to run. The default, if this variable is unset or empty, is ETH. The options are:
ETH, which runs an Ethereum devnet on localhost:8545
ALGO, which runs an Algorand devnet on localhost:4180 and an Algorand indexer on localhost:8980
The environment variable REACH_DEBUG enables some additional debugging information for the Algorand devnet, which is accessible via http://localhost:9392
$ reach rpc-server
starts an instance of the Reach RPC Server using all of the same options and defaults as reach run.
reach rpc-server supports the following options:
The environment variable REACH_RPC_KEY is used to determine the RPC server key. If not defined, it defaults to opensesame, and a warning will appear in the console stating that the development key is being used.
In a production context this key must be kept secret, and it should be randomly generated with a suitably strong method, such as:
$ head -c 24 /dev/urandom | base64
The environment variable REACH_RPC_PORT is used to determine which port to bind to. It defaults to 3000.
$ reach rpc-run CMD
is a convenient means of launching a pre-configured RPC server and frontend which are suitable for development purposes. It uses a REACH_RPC_KEY value of opensesame (the standard development API key), and sets REACH_RPC_TLS_REJECT_UNVERIFIED to 0.
You can easily kill and remove all Docker containers by executing
$ reach docker-reset
This can be a useful thing to try if your Docker containers stop responding to requests or otherwise misbehave, or if you have updated your Reach images (with reach update) but those changes are not taking effect. This command is a loose approximation of "turning Docker off and on again." It will affect all Docker containers on your machine, not just those created by Reach.
You can upgrade your Reach installation by executing
$ reach upgrade
This may change the default version used by reach commands.
You can update the Docker images used by your Reach installation by executing
$ reach update
This may change the patch version used by reach commands.
You can see what version of Reach you have installed by running
$ reach version
You can see which exact versions of Reach Docker images you are using by running
$ reach hashes
This is more precise, but less readable, than reach version, in that each hash refers to the git commit used to build the image.