Skip to main content

Starstream DSL

The Starstream DSL is a domain-specific language, similar to Compact but Utxo-based instead of account based.

The star features of the Starstream DSL are:

  • Defining Utxos as coroutines.
  • Typed effect handling.

Note: the Starstream compiler and VM are still a work in progress, so not everything described below is implemented.

Program

A Starstream program is contained in a single source file, compiled as a unit. Each file consists of top-level items, each of which can be one of the following:

ItemSyntax example
ImportTo be determined
Constantconst Name = Expression;
Typedeftypedef Name = Type;
Abiabi Name { ... }
Utxoutxo Name { ... }
Tokentoken Name { ... }
Scriptscript { ... }

Import

Once compiled, Starstream imports are content-addressed.

Constant

Defines a reusable constant with a particular expression as its value.

Typedef

Defines a reusable alias from a name to a type.

Abi

Abi Function

Abi Effect

Abi Event

Abi Error

Utxo

Each utxo block defines a new Utxo type with a specific name. The block contains a variety of UTXO items:

UTXO ItemSyntax example
Mainmain(arg: Type, ...) { ... }
Storagestorage { Name: Type; ... }
ABI implementationimpl AbiName { ... }

Utxo Main

The main block contains the code that defines the primary behavior and lifetime of the Utxo. It can optionally take parameters used to construct the UTXO. The interior of the block is a series of statements.

Utxo Storage

The storage block contains a series of public variable declarations, each with a name and a type.

Utxo Impl

Token

Token Mint

Token Bind

Token Unbind

Token Burn

Script

A script block contains a series of functions which can be called by users at the top level of a Starstream transaction.

Function

Statement

Expression

Type