trait Box extends AnyRef
Runtime representation of Ergo boxes used during execution of ErgoTree operations.
- See also
- Alphabetic
- By Inheritance
- Box
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
bytes: Coll[Byte]
Serialized bytes of this box's content, including proposition bytes.
-
abstract
def
bytesWithoutRef: Coll[Byte]
Serialized bytes of this box's content, excluding transactionId and index of output.
-
abstract
def
creationInfo: (Int, Coll[Byte])
If
tx
is a transaction which generated this box, thencreationInfo._1
is a height of the tx's block.If
tx
is a transaction which generated this box, thencreationInfo._1
is a height of the tx's block. ThecreationInfo._2
is a serialized transaction identifier followed by box index in the transaction outputs. -
abstract
def
executeFromRegister[T](regId: Byte)(implicit cT: RType[T]): T
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 toT
-
abstract
def
getReg[T](i: Int)(implicit cT: RType[T]): Option[T]
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 theOption[Int]
type.For example
val x = SELF.R4[Int]
expects the register, if it is present, to have typeInt
. At runtime the corresponding type descriptor is passed ascT
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 typeOption[T]
for any T. (In the example above T is equal toInt
). Callingx.get
fails when x is equal to None, butx.isDefined
succeeds and returnsfalse
. 2) If the register contains a valuev
of typeInt
. Thenval x = SELF.R4[Int]
succeeds and returnsSome(v)
, which is a valid value of typeOption[Int]
. In this case, callingx.get
succeeds and returns the valuev
of typeInt
. Callingx.isDefined
returnstrue
. 3) If the register contains a valuev
of type T other thenInt
. Thenval x = SELF.R4[Int]
fails, because there is no way to return a valid value of typeOption[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
`sigmastate.eval.InvalidType`
exception when the type of the register value is different from cT.
-
abstract
def
id: Coll[Byte]
Blake2b256 hash of this box's content, basically equals to
blake2b256(bytes)
-
abstract
def
propositionBytes: Coll[Byte]
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)
- abstract def registers: Coll[AnyValue]
-
abstract
def
tokens: Coll[(Coll[Byte], Long)]
Secondary tokens
-
abstract
def
value: Long
Mandatory: Monetary value, in Ergo tokens (NanoErg unit of measure)
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
R0[T](implicit cT: RType[T]): Option[T]
Mandatory: Monetary value, in Ergo tokens
-
def
R1[T](implicit cT: RType[T]): Option[T]
Mandatory: Guarding script
-
def
R2[T](implicit cT: RType[T]): Option[T]
Mandatory: Secondary tokens
-
def
R3[T](implicit cT: RType[T]): Option[T]
Mandatory: Reference to transaction and output id where the box was created
-
def
R4[T](implicit cT: RType[T]): Option[T]
Non-mandatory register
-
def
R5[T](implicit cT: RType[T]): Option[T]
Non-mandatory register
-
def
R6[T](implicit cT: RType[T]): Option[T]
Non-mandatory register
-
def
R7[T](implicit cT: RType[T]): Option[T]
Non-mandatory register
-
def
R8[T](implicit cT: RType[T]): Option[T]
Non-mandatory register
-
def
R9[T](implicit cT: RType[T]): Option[T]
Non-mandatory register
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- Box → AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()