Trait

special.sigma

Context

Related Doc: package sigma

Permalink

trait Context extends AnyRef

Runtime representation of Context ErgoTree type. Represents data available in Sigma language using CONTEXT global variable.

Annotations
@Liftable() @WithMethodCallRecognizers()
Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Context
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def HEIGHT: Int

    Permalink

    Height (block number) of the block which is currently being validated.

  2. abstract def INPUTS: Coll[Box]

    Permalink

    A collection of inputs of the current transaction, the transaction where selfBox is one of the inputs.

  3. abstract def LastBlockUtxoRootHash: AvlTree

    Permalink

    Authenticated dynamic dictionary digest representing Utxo state before current state.

  4. abstract def OUTPUTS: Coll[Box]

    Permalink

    A collection of outputs of the current transaction.

  5. abstract def SELF: Box

    Permalink

    Box whose proposition is being currently executing

  6. abstract def activatedScriptVersion: Byte

    Permalink

    Maximum version of ErgoTree currently activated on the network.

    Maximum version of ErgoTree currently activated on the network. See ErgoLikeContext class for details.

  7. abstract def builder: SigmaDslBuilder

    Permalink
  8. abstract def currentErgoTreeVersion: Byte

    Permalink

    The version of ErgoTree currently executed by interpreter.

    The version of ErgoTree currently executed by interpreter. See ErgoLikeContext class for details.

  9. abstract def dataInputs: Coll[Box]

    Permalink

    A collection of inputs of the current transaction that will not be spent.

  10. abstract def getVar[T](id: Byte)(implicit cT: RType[T]): Option[T]

    Permalink

    Extracts Context variable by id and type.

    Extracts Context variable by id and type. ErgoScript is typed, so accessing a the variables is an operation which involves some expected type given in brackets. Thus getVar[Int](id) expression should evaluate to a valid value of the Option[Int] type.

    For example val x = getVar[Int](10) expects the variable, if it is present, to have type Int. At runtime the corresponding type descriptor is passed as cT parameter.

    There are three cases: 1) If the variable doesn't exist. Then val x = getVar[Int](id) succeeds and returns the None value, which conforms to any value of type Option[T] for any T. (In the example above T is equal to Int). Calling x.get fails when x is equal to None, but x.isDefined succeeds and returns false. 2) If the variable contains a value v of type Int. Then val x = getVar[Int](id) succeeds and returns Some(v), which is a valid value of type Option[Int]. In this case, calling x.get succeeds and returns the value v of type Int. Calling x.isDefined returns true. 3) If the variable contains a value v of type T other then Int. Then val x = getVar[Int](id) fails, because there is no way to return a valid value of type Option[Int]. The value of variable is present, so returning it as None would break the typed semantics of variables collection.

    In some use cases one variable may have values of different types. To access such variable an additional variable can be used as a tag.

      val tagOpt = getVar[Int](id)
      val res = if (tagOpt.isDefined) {
        val tag = tagOpt.get
        if (tag == 1) {
          val x = getVar[Int](id2).get
          // compute res using value x is of type Int
        } else if (tag == 2) {
          val x = getVar[GroupElement](id2).get
          // compute res using value x is of type GroupElement
        } else if (tag == 3) {
          val x = getVar[ Array[Byte] ](id2).get
          // compute res using value x of type Array[Byte]
        } else {
          // compute `res` when `tag` is not 1, 2 or 3
        }
      }
      else {
        // compute value of res when the variable is not present
      }
    

    T

    expected type of the variable.

    id

    zero-based identifier of the variable.

    returns

    Some(value) if the variable is defined in the context AND has the given type. None otherwise

    Exceptions thrown

    special.sigma.InvalidType exception when the type of the variable value is different from cT.

  11. abstract def headers: Coll[Header]

    Permalink

    A fixed number of last block headers in descending order (first header is the newest one)

    A fixed number of last block headers in descending order (first header is the newest one)

    Since

    2.0

  12. abstract def minerPubKey: Coll[Byte]

    Permalink
  13. abstract def preHeader: PreHeader

    Permalink

    Since

    2.0

  14. abstract def selfBoxIndex: Int

    Permalink

    Zero based index in inputs of selfBox.

    Zero based index in inputs of selfBox. -1 if self box is not in the INPUTS collection.

  15. abstract def vars: Coll[AnyValue]

    Permalink

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  16. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  17. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped