Mandatory: Monetary value, in Ergo tokens
Mandatory: Monetary value, in Ergo tokens
Mandatory: Guarding script
Mandatory: Guarding script
Mandatory: Secondary tokens
Mandatory: Secondary tokens
Mandatory: Reference to transaction and output id where the box was created
Mandatory: Reference to transaction and output id where the box was created
Non-mandatory register
Non-mandatory register
Non-mandatory register
Non-mandatory register
Non-mandatory register
Non-mandatory register
Non-mandatory register
Non-mandatory register
Non-mandatory register
Non-mandatory register
Non-mandatory register
Non-mandatory register
Serialized bytes of this box's content, including proposition bytes.
Serialized bytes of this box's content, including proposition bytes.
Serialized bytes of this box's content, excluding transactionId and index of output.
Serialized bytes of this box's content, excluding transactionId and index of output.
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.
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)
result type of the deserialized script.
identifier of the register
result of the script execution in the current context
Mainnet
IllegalArgumentException
if the actual script type doesn't conform to 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 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 }
expected type of the register.
zero-based identifier of the register.
Some(value) if the register is defined AND has the given type. None otherwise
2.0
special.sigma.InvalidType
exception when the type of the register value is
different from cT.
Blake2b256 hash of this box's content, basically equals to blake2b256(bytes)
Blake2b256 hash of this box's content, basically equals to blake2b256(bytes)
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)
Secondary tokens
Secondary tokens
Mandatory: Monetary value, in Ergo tokens (NanoErg unit of measure)
Mandatory: Monetary value, in Ergo tokens (NanoErg unit of measure)
The data value wrapped by this wrapper.
The data value wrapped by this wrapper.
A default implementation of Box interface.
Box for detailed descriptions