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:
Item | Syntax example |
---|---|
Import | To be determined |
Constant | const Name = Expression; |
Typedef | typedef Name = Type; |
Abi | abi Name { ... } |
Utxo | utxo Name { ... } |
Token | token Name { ... } |
Script | script { ... } |
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 Item | Syntax example |
---|---|
Main | main(arg: Type, ...) { ... } |
Storage | storage { Name: Type; ... } |
ABI implementation | impl 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.