Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions Other

Functions | Assertion

Functions | Branching

Functions | Loop

Functions | Result Statements

Functions | Set Statements

Functions | Set expressions

Functions | Type Handling

Functions | Variable Methods

Other Functions

  • DeleteMapEntry(expression: IExpression<MichelsonType>, key: IExpression<MichelsonType>, line?: LineInfo): Statement
  • Delete map entry.

    DeleteMapEntry(GetVariable("some_map"), arg);
    

    Parameters

    • expression: IExpression<MichelsonType>

      A map expression.

    • key: IExpression<MichelsonType>

      The indexing key to be deleted.

    • line: LineInfo = ...

      Source code line information (Used in error messages)

    Returns Statement

    A statement

| Assertion Functions

  • Require(condition: IExpression<MichelsonType>, errorMsg?: IExpression<MichelsonType>, line?: LineInfo): Statement
  • Test a condition and interrupt the smart-contract execution if the condition is false. (The whole operation is rollbacked)

    Require(LessThanOrEqual(ContractStorage(), Nat(10)), String("LessThanOrEqual to 10"));
    

    Parameters

    • condition: IExpression<MichelsonType>
    • errorMsg: IExpression<MichelsonType> = ...

      The value to be included in the error trace.

    • line: LineInfo = ...

      Source code line information (Used in error messages)

    Returns Statement

    A statement

| Branching Functions

  • If(condition: IExpression<MichelsonType>, thenStatements?: IToString[], elseStatements?: IToString[], line?: LineInfo): IfStatment
  • A (If) statement.

    If(GreaterThan(ContractStorage(), Nat(5)))
    .Then([SetValue(ContractStorage(), Nat(5))])
    .Else([])

    Parameters

    • condition: IExpression<MichelsonType>
    • Optional thenStatements: IToString[]

      Statements to be applied if the condition is true.

    • Optional elseStatements: IToString[]

      Statements to be applied if the condition is false.

    • line: LineInfo = ...

      Source code line information (Used in error messages)

    Returns IfStatment

    A statement

  • MatchVariant(variant: IExpression<option | or>, argumentName?: string, line?: LineInfo): VariantMatchStatement
  • Switch statement used to match branches on variant expressions.

    MatchVariant(arg)
    .Case('action1', (action) => [SetValue(ContractStorage(), action)])
    .Case('action2', (action) => [SetValue(ContractStorage(), action)])

    Parameters

    • variant: IExpression<option | or>

      Variant expression

    • argumentName: string = ...

      An optional argument name

    • line: LineInfo = ...

      Source code line information (Used in error messages)

    Returns VariantMatchStatement

    A statement

| Loop Functions

  • For(from: IExpression<MichelsonType>, to: IExpression<MichelsonType>, increment: IExpression<MichelsonType>, statements?: IToString[], iteratorName?: string, line?: LineInfo): ForStatement
  • A basic (for) loop.

    For(Nat(0), Nat(10), Nat(1)).Do((i) => [SetValue(ContractStorage(), Add(ContractStorage(), i))]);
    

    Parameters

    • from: IExpression<MichelsonType>

      The initial value

    • to: IExpression<MichelsonType>

      The target value

    • increment: IExpression<MichelsonType>

      The incrementor

    • Optional statements: IToString[]

      The statements inside the loop body

    • iteratorName: string = ...

      The variable name being incremented inside the loop

    • line: LineInfo = ...

      Source code line information (Used in error messages)

    Returns ForStatement

    A statement

  • ForEachOf(list: IExpression<MichelsonType>, statements?: IToString[], iteratorName?: string, line?: LineInfo): ForEachStatement
  • A (forEach) loop.

    ForEachOf(arg)
    .Do((i) => [SetValue(ContractStorage(), Add(ContractStorage(), i))]);

    Parameters

    • list: IExpression<MichelsonType>

      The list to be iterated over

    • statements: IToString[] = []

      The statements inside the loop body

    • iteratorName: string = ...

      The iterator name

    • line: LineInfo = ...

      Source code line information (Used in error messages)

    Returns ForEachStatement

    A statement

  • While(condition: IExpression<MichelsonType>, statements?: IToString[], line?: LineInfo): WhileStatement
  • A basic (while) loop.

    While(LessThanOrEqual(ContractStorage(), Nat(10)))
    .Do([SetValue(ContractStorage(), Add(ContractStorage(), Nat(1)))]);

    Parameters

    • condition: IExpression<MichelsonType>
    • Optional statements: IToString[]

      The statements inside the loop body

    • line: LineInfo = ...

      Source code line information (Used in error messages)

    Returns WhileStatement

    A statement

| Result Statements Functions

  • FailWith(errorMsg?: IExpression<MichelsonType>, line?: LineInfo): Statement
  • Interrupt the smart-contract execution. (The whole operation is rollbacked)

    FailWith(String("SOME ERROR MESSAGE"));
    

    Parameters

    • errorMsg: IExpression<MichelsonType> = ...

      The value to be included in the error trace.

    • line: LineInfo = ...

      Source code line information (Used in error messages)

    Returns Statement

    A statement

  • Return(expression: IExpression<MichelsonType>, line?: LineInfo): Statement
  • Return statement used inside lambdas and views.

    Lambda().setInputType(TString()).code((arg) => [Return(arg)])
    

    Parameters

    • expression: IExpression<MichelsonType>

      Method returned expression

    • line: LineInfo = ...

      Source code line information (Used in error messages)

    Returns Statement

    A statement

| Set Statements Functions

  • AddElementToSet(set: IExpression<set>, element: IExpression<MichelsonType>, line?: LineInfo): Statement
  • Add element to set.

    AddElementToSet(Set([Nat(1)]), Nat(2));
    

    Parameters

    • set: IExpression<set>

      An expression of type set.

    • element: IExpression<MichelsonType>

      The element to be added.

    • line: LineInfo = ...

      Source code line information (Used in error messages)

    Returns Statement

    An expression of type list.

| Set expressions Functions

  • RemoveElementFromSet(set: IExpression<set>, element: IExpression<MichelsonType>, line?: LineInfo): Statement
  • Remove element to set.

    RemoveElementFromSet(Set([Nat(1)]), Nat(1));
    

    Parameters

    • set: IExpression<set>

      An expression of type set.

    • element: IExpression<MichelsonType>

      The element to be removed.

    • line: LineInfo = ...

      Source code line information (Used in error messages)

    Returns Statement

    An expression of type list.

| Type Handling Functions

  • SetType(expression: IExpression<MichelsonType>, type: IType<TypeAtom>, line?: LineInfo): Statement
  • Set expression type.

    Lambda().setInputType(TString()).code((arg) => [SetType(arg, TBool())])
    

    Parameters

    • expression: IExpression<MichelsonType>
    • type: IType<TypeAtom>

      Expression type.

    • line: LineInfo = ...

      Source code line information (Used in error messages)

    Returns Statement

    A statement

| Variable Methods Functions

  • NewVariable(name: string, value: IExpression<MichelsonType>, mutable?: boolean, line?: LineInfo): Statement
  • Declare a new variable.

    // Mutable
    NewVariable("a", String("HELLO WORLD"));
    // Unmutable
    NewVariable("b", String("HELLO WORLD"), false);

    Parameters

    • name: string

      Variable name

    • value: IExpression<MichelsonType>

      Variable initial value

    • mutable: boolean = true

      Optional flag that can be used to set the variable as final (false: final, true: mutable)

    • line: LineInfo = ...

      Source code line information (Used in error messages)

    Returns Statement

    A statement

  • SetValue(source: IExpression<MichelsonType>, value: IExpression<MichelsonType>, line?: LineInfo): Statement
  • Assign value to variable.

    SetValue(ContractStorage(), Nat(1));
    

    Parameters

    • source: IExpression<MichelsonType>

      The variable to be updated

    • value: IExpression<MichelsonType>

      Value to be assigned

    • line: LineInfo = ...

      Source code line information (Used in error messages)

    Returns Statement

    A statement

Generated using TypeDoc