trait Context extends AnyRef
Runtime representation of Context ErgoTree type.
Represents data available in Sigma language using CONTEXT
global variable.
- Alphabetic
- By Inheritance
- Context
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
HEIGHT: Int
Height (block number) of the block which is currently being validated.
-
abstract
def
INPUTS: Coll[Box]
A collection of inputs of the current transaction, the transaction where selfBox is one of the inputs.
-
abstract
def
LastBlockUtxoRootHash: AvlTree
Authenticated dynamic dictionary digest representing Utxo state before current state.
-
abstract
def
OUTPUTS: Coll[Box]
A collection of outputs of the current transaction.
-
abstract
def
SELF: Box
Box whose proposition is being currently executing
-
abstract
def
activatedScriptVersion: Byte
Maximum version of ErgoTree currently activated on the network.
Maximum version of ErgoTree currently activated on the network. See ErgoLikeContext class for details.
- abstract def builder: SigmaDslBuilder
-
abstract
def
currentErgoTreeVersion: Byte
The version of ErgoTree currently executed by interpreter.
The version of ErgoTree currently executed by interpreter. See ErgoLikeContext class for details.
-
abstract
def
dataInputs: Coll[Box]
A collection of inputs of the current transaction that will not be spent.
-
abstract
def
getVar[T](id: Byte)(implicit cT: RType[T]): Option[T]
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 theOption[Int]
type.For example
val x = getVar[Int](10)
expects the variable, if it is present, to have typeInt
. At runtime the corresponding type descriptor is passed ascT
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 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 variable contains a valuev
of typeInt
. Thenval x = getVar[Int](id)
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 variable contains a valuev
of type T other thenInt
. Thenval x = getVar[Int](id)
fails, because there is no way to return a valid value of typeOption[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
`sigmastate.eval.InvalidType`
exception when the type of the variable value is different from cT.
-
abstract
def
headers: Coll[Header]
A fixed number of last block headers in descending order (first header is the newest one)
-
abstract
def
minerPubKey: Coll[Byte]
Bytes of encoded miner's public key.
Bytes of encoded miner's public key. Same as
preHeader.minerPk.getEncoded
-
abstract
def
preHeader: PreHeader
Fields of a new block header, that can be predicted by a miner before block's formation
-
abstract
def
selfBoxIndex: Int
Zero based index in
inputs
ofselfBox
. - abstract def vars: Coll[AnyValue]
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
-
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
- 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()