Trait

special.sigma

Box

Related Doc: package sigma

Permalink

trait Box extends AnyRef

Runtime representation of Ergo boxes used during execution of ErgoTree operations.

Annotations
@Liftable() @WithMethodCallRecognizers()
See also

org.ergoplatform.ErgoBox

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Box
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def bytes: Coll[Byte]

    Permalink

    Serialized bytes of this box's content, including proposition bytes.

  2. abstract def bytesWithoutRef: Coll[Byte]

    Permalink

    Serialized bytes of this box's content, excluding transactionId and index of output.

  3. abstract def creationInfo: (Int, Coll[Byte])

    Permalink

    If tx is a transaction which generated this box, then creationInfo._1 is a height of the tx's block.

    If tx is a transaction which generated this box, then creationInfo._1 is a height of the tx's block. The creationInfo._2 is a serialized transaction identifier followed by box index in the transaction outputs.

  4. abstract def executeFromRegister[T](regId: Byte)(implicit cT: RType[T]): T

    Permalink

    Extracts register as Coll[Byte], deserializes it to script and then executes this script in the current context.

    Extracts register as Coll[Byte], deserializes it to script and then executes this script in the current context. The original Coll[Byte] of the script is available as getReg[Coll[Byte]](id)

    T

    result type of the deserialized script.

    regId

    identifier of the register

    returns

    result of the script execution in the current context

    Since

    Mainnet

    Exceptions thrown

    IllegalArgumentException if the actual script type doesn't conform to T

  5. abstract def getReg[T](i: Int)(implicit cT: RType[T]): Option[T]

    Permalink

    Extracts register by id and type.

    Extracts register by id and type. ErgoScript is typed, so accessing a register is an operation which involves some expected type given in brackets. Thus SELF.R4[Int] expression should evaluate to a valid value of the Option[Int] type.

    For example val x = SELF.R4[Int] expects the register, 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 register doesn't exist. Then val x = SELF.R4[Int] 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 register contains a value v of type Int. Then val x = SELF.R4[Int] 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 register contains a value v of type T other then Int. Then val x = SELF.R4[Int] fails, because there is no way to return a valid value of type Option[Int]. The value of register is present, so returning it as None would break the typed semantics of registers collection.

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

      val tagOpt = SELF.R5[Int]
      val res = if (tagOpt.isDefined) {
        val tag = tagOpt.get
        if (tag == 1) {
          val x = SELF.R4[Int].get
          // compute res using value x is of type Int
        } else if (tag == 2) {
          val x = SELF.R4[GroupElement].get
          // compute res using value x is of type GroupElement
        } else if (tag == 3) {
          val x = SELF.R4[ Array[Byte] ].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 register is not present
      }
    

    T

    expected type of the register.

    i

    zero-based identifier of the register.

    returns

    Some(value) if the register is defined AND has the given type. None otherwise

    Since

    2.0

    Exceptions thrown

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

  6. abstract def id: Coll[Byte]

    Permalink

    Blake2b256 hash of this box's content, basically equals to blake2b256(bytes)

  7. abstract def propositionBytes: Coll[Byte]

    Permalink

    Serialized bytes of guarding script, which should be evaluated to true in order to open this box.

    Serialized bytes of guarding script, which should be evaluated to true in order to open this box. (aka spend it in a transaction)

  8. abstract def registers: Coll[AnyValue]

    Permalink
  9. abstract def tokens: Coll[(Coll[Byte], Long)]

    Permalink

    Secondary tokens

  10. abstract def value: Long

    Permalink

    Mandatory: Monetary value, in Ergo tokens (NanoErg unit of measure)

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. def R0[T](implicit cT: RType[T]): Option[T]

    Permalink

    Mandatory: Monetary value, in Ergo tokens

  5. def R1[T](implicit cT: RType[T]): Option[T]

    Permalink

    Mandatory: Guarding script

  6. def R2[T](implicit cT: RType[T]): Option[T]

    Permalink

    Mandatory: Secondary tokens

  7. def R3[T](implicit cT: RType[T]): Option[T]

    Permalink

    Mandatory: Reference to transaction and output id where the box was created

  8. def R4[T](implicit cT: RType[T]): Option[T]

    Permalink

    Non-mandatory register

  9. def R5[T](implicit cT: RType[T]): Option[T]

    Permalink

    Non-mandatory register

  10. def R6[T](implicit cT: RType[T]): Option[T]

    Permalink

    Non-mandatory register

  11. def R7[T](implicit cT: RType[T]): Option[T]

    Permalink

    Non-mandatory register

  12. def R8[T](implicit cT: RType[T]): Option[T]

    Permalink

    Non-mandatory register

  13. def R9[T](implicit cT: RType[T]): Option[T]

    Permalink

    Non-mandatory register

  14. final def asInstanceOf[T0]: T0

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

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

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

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

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

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

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

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

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

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

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

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

    Permalink
    Definition Classes
    Box → AnyRef → Any
    Annotations
    @Internal()
  27. final def wait(): Unit

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

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

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

Inherited from AnyRef

Inherited from Any

Ungrouped