On this page:
5.4.3.1 Statements
5.4.3.1.1 deploy
deploy
5.4.3.1.2 set  Options
set  Options
deploy  Mode
verify  Arithmetic
verify  Per  Connector
connectors
ETH
ALGO
5.4.3.2 Expressions
5.4.3.2.1 Participant Definition
Participant
Participant  Class
5.4.3.2.2 View Definition
View
0.1.3
5.4.3 Application Initialization

The body of Reach.app is an application initialization. It defines the various participants and views of the DApp, as well as sets compilation options. It is finalized with deploy() and then the application begins in a step.

5.4.3.1 Statements

Any statements valid for a computation are valid for application initialization. However, some additional statements are allowed.

5.4.3.1.1 deploy

deploy(); 

A deploy statement, written deploy();, deploys the DApp and finalizes all of the available participants, views, and compilation options.

Its continuation is a step, which means its content is specified by Steps. It represents the body of the DApp to be compiled.

5.4.3.1.2 setOptions

setOptions({ verifyArithmetic: true });
setOptions({}); 

The compilation options for the DApp may be set by calling setOptions(OBJ_EXPR); where OBJ_EXPR is an object with the following keys and values:

deployMode

 

'constructor' (default) or 'firstMsg'

 

Determines whether contract should be deployed independently ('constructor') or as part of the first publication ('firstMsg'). If deployed as part of the first publication, then the first publication must precede all uses of wait and .timeout. See the guide on deployment modes for a discussion of why to choose a particular mode.

 

 

 

 

 

verifyArithmetic

 

true or false (default)

 

Determines whether arithmetic operations automatically introduce static assertions that they do not overflow beyond UInt.max. This defaults to false, because it is onerous to verify. We recommend turning it on before final deployment, but leaving it off during development. When it is false, connectors will ensure that overflows do not actually occur on the network.

 

 

 

 

 

verifyPerConnector

 

true or false (default)

 

Determines whether verification is done per connector, or once for a generic connector. When this is true, then connector-specific constants, like UInt.max, will be instantiated to literal numbers. This concretization of these constants can induce performance degradation in the verifier.

 

 

 

 

 

connectors

 

[ETH, ALGO] (default)

 

A tuple of the connectors that the application should be compiled for. By default, all available connectors are chosen.

5.4.3.2 Expressions

Any expressions valid for a computation are valid for application initialization. However, some additional expressions are allowed.

5.4.3.2.1 Participant Definition

A participant and participant class may be declared with

Participant(participantName, participantInteractInterface)

and

ParticipantClass(participantName, participantInteractInterface)

respectively.

participantName is a string which indicates the name of the participant function in the generated backend code. Each participantName must be unique.

participantInteractInterface is a participant interact interface, an object where each field indicates the type of a function or value which must be provided to the backend by the frontend for interacting with the participant.

5.4.3.2.2 View Definition

Views are defined in application initialization and then they are set in consensus steps. Both of these steps are in Reach. They are accessed by frontends by using the Reach standard library of the frontend language, such as JavaScript.

View('NFT', { owner: Address })

A view is defined with View(viewName, viewInterface), where viewName is a string that labels the view and viewInterface is an object where each field indicates the type of a function or value provided by the contract associated with the specified DApp. These views are available in frontends via the ctc.getViews function. In the DApp, the result of this application argument is referred to as a view object.