Emulator

scalus.cardano.node.Emulator
See theEmulator companion object
class Emulator extends EmulatorBase

An in-memory bare-bones node implementation (JVM version with thread-safe state).

Allows submitting transaction and querying UTxO state. Runs validators and mutators against all submitted transactions. The default validator and mutator lists reflect the Cardano Node UTxO related ledger rules.

The rules themselves live in EmulatorBase, shared with the JavaScript emulator; all this class adds is the state cell and the compare-and-set retry that makes concurrent submission safe.

Attributes

See also

scalus.cardano.ledger.rules for the ledger rules

Companion
object
Graph
Supertypes
trait InteropApi
trait EmulatorBase
trait BlockchainProviderTF[Future]
trait BlockchainReaderTF[Future]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Constructors

def this(initialUtxos: Utxos, initialContext: Context, validators: Iterable[Validator], mutators: Iterable[Mutator], initialCertState: CertState, initialDatums: Map[DataHash, Data], chainConfig: ChainConfig)

An emulator in the preset of chainConfig, spec [CF-1]. It has no default arguments: Scala allows them on one overload only, and Java and JavaScript cannot use them.

An emulator in the preset of chainConfig, spec [CF-1]. It has no default arguments: Scala allows them on one overload only, and Java and JavaScript cannot use them.

Attributes

def this(initialUtxos: Utxos = ..., initialContext: Context = ..., validators: Iterable[Validator] = ..., mutators: Iterable[Mutator] = ..., initialCertState: CertState = ..., initialDatums: Map[DataHash, Data] = ..., initialAppliedTxLog: Vector[AppliedTx] = ...)

The 1.4 constructor, in the Instant preset, spec [CF-4]. It keeps its default arguments, so Scala callers can name only the fields they set.

The 1.4 constructor, in the Instant preset, spec [CF-4]. It keeps its default arguments, so Scala callers can name only the fields they set.

Value parameters

initialAppliedTxLog

Deprecated since 1.4.1: the log has no blocks, so status APIs report NotFound for its txs; use snapshot() or ImmutableEmulator.fromEmulator/toEmulator, which keep the blocks. No compiler warning: the parameter has a default.

Attributes

Concrete methods

override def appliedTxLog: Vector[AppliedTx]

Narrowed to Vector — the type this class has always returned.

Narrowed to Vector — the type this class has always returned.

Attributes

Definition Classes

Inherited methods

def addDatum(data: Data): DataHash

addDatum for a datum without its original bytes: the store keeps its canonical CBOR.

addDatum for a datum without its original bytes: the store keeps its canonical CBOR.

Attributes

Returns

the hash of the canonical CBOR of data

Inherited from:
EmulatorBase
def addDatum(datum: KeepRaw[Data]): DataHash

Adds a datum to the datum store getDatum reads, with the bytes it is given, so a UTxO added with addUtxo that holds only the hash of its datum can have the datum found too. Adding a datum the store already holds changes nothing.

Adds a datum to the datum store getDatum reads, with the bytes it is given, so a UTxO added with addUtxo that holds only the hash of its datum can have the datum found too. Adding a datum the store already holds changes nothing.

Attributes

Returns

the hash of the bytes of datum, which is the key getDatum finds it under

Inherited from:
EmulatorBase
def addRewards(credential: Credential, amount: Coin): Unit

Pays amount into the reward balance of a registered account, as the epoch boundary pays rewards in the Haskell ledger. Nothing else changes: no deposit, no pot, no slot.

Pays amount into the reward balance of a registered account, as the epoch boundary pays rewards in the Haskell ledger. Nothing else changes: no deposit, no pot, no slot.

Attributes

Throws
IllegalArgumentException

if credential is not registered, or amount is negative

Inherited from:
EmulatorBase
def addUtxo(input: TransactionInput, output: TransactionOutput): Unit

Adds a UTxO to the ledger directly, bypassing transaction validation. Overwrites any UTxO already sitting at the same input.

Adds a UTxO to the ledger directly, bypassing transaction validation. Overwrites any UTxO already sitting at the same input.

An inline datum on output joins the datum store, so getDatum answers for a script UTxO seeded this way exactly as it does for one produced by a transaction.

Attributes

Inherited from:
EmulatorBase

Index of applied transactions by hash, for O(1) lookup.

Index of applied transactions by hash, for O(1) lookup.

Attributes

Inherited from:
EmulatorBase

Hashes of all applied transactions. Held as a materialized set (derived from appliedTxLog by EmulatorState, so it cannot drift) rather than a per-call key-set view, so access is a plain O(1) field read.

Hashes of all applied transactions. Held as a materialized set (derived from appliedTxLog by EmulatorState, so it cannot drift) rather than a per-call key-set view, so access is a plain O(1) field read.

Attributes

Inherited from:
EmulatorBase
override def cardanoInfo: CardanoInfo

Returns CardanoInfo for this reader.

Returns CardanoInfo for this reader.

This is always available synchronously after the reader is constructed. For emulators, this returns the current context. For remote providers like BlockfrostProvider, the CardanoInfo is fetched during async construction.

Attributes

Definition Classes
Inherited from:
EmulatorBase

Attributes

Inherited from:
EmulatorBase
override def checkTransaction(txHash: TransactionHash): Future[TransactionStatus]

Where the transaction stands, from txStatus: Pending and Confirmed map to themselves, every other status to NotFound, spec [TS-3], [TS-4]. A tx known only from the applied-tx log the emulator was built with has no block, so it is NotFound, as on a node.

Where the transaction stands, from txStatus: Pending and Confirmed map to themselves, every other status to NotFound, spec [TS-3], [TS-4]. A tx known only from the applied-tx log the emulator was built with has no block, so it is NotFound, as on a node.

Authoritative, unlike the inherited default, which infers status from the UTxOs a transaction produced: findUtxos here answers Right(empty) for a transaction it has never seen, and an emulator that has applied a transaction whose outputs are all since spent produces none either.

Attributes

Definition Classes
Inherited from:
EmulatorBase

The epoch of the current slot, ledger-rules spec [ES-9].

The epoch of the current slot, ledger-rules spec [ES-9].

Attributes

Inherited from:
EmulatorBase
def currentSlot: Future[SlotNo]

Returns the current slot number.

Returns the current slot number.

Attributes

Inherited from:
EmulatorBase

The current slot, without the Future wrapper.

The current slot, without the Future wrapper.

An emulator's slot is in-memory state, so the effectful accessor above is a formality imposed by the BlockchainReader interface. Streaming needs the value synchronously while building a chain point, where handing back an already-completed Future and unwrapping it would be pure ceremony.

Attributes

Inherited from:
EmulatorBase
def datums: Map[DataHash, Data]

Every datum this emulator has seen, by hash, decoded. binaryDatums keeps the bytes.

Every datum this emulator has seen, by hash, decoded. binaryDatums keeps the bytes.

Attributes

Inherited from:
EmulatorBase
def diff(from: ChainTip, to: ChainTip): Seq[ChainEvent]

The ChainSync events that take a follower from from to to, two tips of the block tree, spec section 12.1: one RollBackward to their common ancestor when from is not an ancestor of to, then one RollForward per block up to to, in height order. ChainTip.origin is genesis.

The ChainSync events that take a follower from from to to, two tips of the block tree, spec section 12.1: one RollBackward to their common ancestor when from is not an ancestor of to, then one RollForward per block up to to, in height order. ChainTip.origin is genesis.

Experimental: ChainEvent, AppliedBlock and AppliedTransaction live in scalus.cardano.node.stream.internal, outside the binary-compatibility check, and may change in a minor release.

Attributes

Throws
IllegalArgumentException

if a tip is not a block of the tree, with the same slot and height

Inherited from:
EmulatorBase
def donation: Coin

The donations of this epoch. The next epoch boundary moves them into treasury.

The donations of this epoch. The next epoch boundary moves them into treasury.

Attributes

Inherited from:
EmulatorBase

Evaluator mode the emulator runs Plutus scripts in (e.g. Validate vs EvaluateAndComputeCost). Exposed so snapshots such as ImmutableEmulator.fromEmulator can preserve it rather than silently reverting to the Context default.

Evaluator mode the emulator runs Plutus scripts in (e.g. Validate vs EvaluateAndComputeCost). Exposed so snapshots such as ImmutableEmulator.fromEmulator can preserve it rather than silently reverting to the Context default.

Attributes

Inherited from:
EmulatorBase
override def executionContext: ExecutionContext

Emulator uses parasitic EC since all operations are synchronous.

Emulator uses parasitic EC since all operations are synchronous.

Attributes

Definition Classes
Inherited from:
EmulatorBase
def fees: Coin

The fee pot: the fees of the applied transactions since the last epoch boundary, plus those of the epoch before it, which the next boundary takes out (deltaF, ledger-rules spec [RW-12]).

The fee pot: the fees of the applied transactions since the last epoch boundary, plus those of the epoch before it, which the next boundary takes out (deltaF, ledger-rules spec [RW-12]).

Attributes

Inherited from:
EmulatorBase

Fetches the latest protocol parameters from the network.

Fetches the latest protocol parameters from the network.

Attributes

Inherited from:
EmulatorBase
def findUtxo(input: TransactionInput): Future[Either[UtxoQueryError, Utxo]]

Find a single UTxO by its transaction input.

Find a single UTxO by its transaction input.

Attributes

Returns

Right(utxo) if found, Left(NotFound) otherwise

Inherited from:
BlockchainReaderTF
override def findUtxos(query: UtxoQuery): Future[Either[UtxoQueryError, Utxos]]

Find UTxOs using a type-safe query.

Find UTxOs using a type-safe query.

Value parameters

query

The query specifying source, filters, and pagination

Attributes

Returns

Either a UtxoQueryError or the matching UTxOs

Definition Classes
Inherited from:
EmulatorBase
def findUtxos(query: UtxoQuery, view: ChainView): Future[Either[ChainViewError, Utxos]]

findUtxosSync with a view, in a Future, spec [VW-3].

findUtxosSync with a view, in a Future, spec [VW-3].

Attributes

Inherited from:
EmulatorBase
def findUtxos(address: Address): Future[Either[UtxoQueryError, Utxos]]

Find all UTxOs at the given address.

Find all UTxOs at the given address.

Attributes

Inherited from:
BlockchainReaderTF
def findUtxos(inputs: Set[TransactionInput]): Future[Either[UtxoQueryError, Utxos]]

Find UTxOs by a set of transaction inputs (fails with NotFound if not all are found).

Find UTxOs by a set of transaction inputs (fails with NotFound if not all are found).

Attributes

Inherited from:
BlockchainReaderTF

All UTxOs at the given address in the ledger state view reads, spec [VW-3].

All UTxOs at the given address in the ledger state view reads, spec [VW-3].

Attributes

Inherited from:
EmulatorJavaApi (hidden)
final def findUtxosForAddress(address: Address): List[Utxo]

All UTxOs at the given address as a Java list.

All UTxOs at the given address as a Java list.

Attributes

Inherited from:
EmulatorJavaApi (hidden)
final def findUtxosForAddressAsync(address: Address): CompletableFuture[List[Utxo]]

CompletableFuture variant of findUtxosForAddress.

CompletableFuture variant of findUtxosForAddress.

Attributes

Inherited from:
EmulatorJavaApi (hidden)
final def findUtxosForInputs(inputs: Set[TransactionInput]): List[Utxo]

The UTxOs among inputs that are unspent, as a Java list.

The UTxOs among inputs that are unspent, as a Java list.

Attributes

Inherited from:
EmulatorJavaApi (hidden)

findUtxos without the Future. The emulator's state is in memory and its query evaluation is pure, so the effect wrapper is an interface formality — JavaScript and Java callers both want the value.

findUtxos without the Future. The emulator's state is in memory and its query evaluation is pure, so the effect wrapper is an interface formality — JavaScript and Java callers both want the value.

Attributes

Inherited from:
EmulatorBase
def findUtxosSync(query: UtxoQuery, view: ChainView): Either[ChainViewError, Utxos]

The UTxOs that match query in the ledger state view reads, spec [VW-3].

The UTxOs that match query in the ledger state view reads, spec [VW-3].

Attributes

Inherited from:
EmulatorBase
def getAppliedTx(txHash: TransactionHash): Option[AppliedTx]

Look up the full applied-tx record (transaction + slot + spent inputs) by hash.

Look up the full applied-tx record (transaction + slot + spent inputs) by hash.

Attributes

Inherited from:
EmulatorBase

Hashes of all applied transactions as a Java set.

Hashes of all applied transactions as a Java set.

Attributes

Inherited from:
EmulatorJavaApi (hidden)
final def getAppliedTxLog: List[AppliedTx]

The applied-transaction log as a Java list (oldest first).

The applied-transaction log as a Java list (oldest first).

Attributes

Inherited from:
EmulatorJavaApi (hidden)

The applied-transaction record with the given hash, or null if unknown.

The applied-transaction record with the given hash, or null if unknown.

Attributes

Inherited from:
EmulatorJavaApi (hidden)
final def getCurrentEpoch: Long

The epoch of the current slot, ledger-rules spec [ES-9].

The epoch of the current slot, ledger-rules spec [ES-9].

Attributes

Inherited from:
EmulatorJavaApi (hidden)
final def getCurrentSlot: Long

The current slot number.

The current slot number.

Attributes

Inherited from:
EmulatorJavaApi (hidden)
def getDatum(datumHash: DataHash): Future[Option[Data]]

Look up a datum by its hash. Returns None if unknown.

Look up a datum by its hash. Returns None if unknown.

Attributes

Inherited from:
EmulatorBase
final def getDatumOrNull(datumHash: DataHash): Data

The datum with the given hash, or null if unknown.

The datum with the given hash, or null if unknown.

Attributes

Inherited from:
EmulatorJavaApi (hidden)
final def getDatums: Map[DataHash, Data]

All known datums by hash as a Java map.

All known datums by hash as a Java map.

Attributes

Inherited from:
EmulatorJavaApi (hidden)

Attributes

Inherited from:
EmulatorBase
final def getDiff(from: ChainTip, to: ChainTip): List[ChainEvent]

diff as a Java list, spec section 12.1. Experimental, as diff is: the event types live in scalus.cardano.node.stream.internal and may change in a minor release.

diff as a Java list, spec section 12.1. Experimental, as diff is: the event types live in scalus.cardano.node.stream.internal and may change in a minor release.

Attributes

Inherited from:
EmulatorJavaApi (hidden)
final def getGovState: GovState

The gov state: proposals in submission order with their votes, the committee and the constitution, spec [ES-9]. One proposal is getGovState.proposal(id), D35.

The gov state: proposals in submission order with their votes, the committee and the constitution, spec [ES-9]. One proposal is getGovState.proposal(id), D35.

Attributes

Inherited from:
EmulatorJavaApi (hidden)
final def getLedgerFailureNames(transaction: Transaction): List[String]

The cardano-ledger names of every ledger failure of transaction, in the ledger's order, for example ["BadInputsUTxO", "OutsideValidityIntervalUTxO"]; empty when the ledger rules accept it. A dry run: the state does not change. Ledger-rules spec [FL-8]; see ledgerFailures.

The cardano-ledger names of every ledger failure of transaction, in the ledger's order, for example ["BadInputsUTxO", "OutsideValidityIntervalUTxO"]; empty when the ledger rules accept it. A dry run: the state does not change. Ledger-rules spec [FL-8]; see ledgerFailures.

Attributes

Inherited from:
EmulatorJavaApi (hidden)

The whole ledger state in the shape of the node's NewEpochState, read from one state, ledger-rules spec D122; its Java getters are those of NewEpochStatePlatform, D128.

The whole ledger state in the shape of the node's NewEpochState, read from one state, ledger-rules spec D122; its Java getters are those of NewEpochStatePlatform, D128.

Attributes

Inherited from:
EmulatorJavaApi (hidden)
final def getMempoolTxs: List[Transaction]

The pending txs, oldest first, as a Java list.

The pending txs, oldest first, as a Java list.

Attributes

Inherited from:
EmulatorJavaApi (hidden)

The ratify result the last epoch boundary computed, which the next boundary enacts, ledger-rules spec [ES-9b].

The ratify result the last epoch boundary computed, which the next boundary enacts, ledger-rules spec [ES-9b].

Attributes

Inherited from:
EmulatorJavaApi (hidden)

The reward update the next epoch boundary pays, or null before the first boundary, ledger-rules spec [ES-9a].

The reward update the next epoch boundary pays, or null before the first boundary, ledger-rules spec [ES-9a].

Attributes

Inherited from:
EmulatorJavaApi (hidden)

The protocol parameters the emulator validates against.

The protocol parameters the emulator validates against.

Attributes

Inherited from:
EmulatorJavaApi (hidden)
final def getReserves: Coin

The reserves, ledger-rules spec [ES-9].

The reserves, ledger-rules spec [ES-9].

Attributes

Inherited from:
EmulatorJavaApi (hidden)
final def getSnapshots: SnapShots

The stake snapshots and the fee snapshot of the last epoch boundary, ledger-rules spec [ES-9a].

The stake snapshots and the fee snapshot of the last epoch boundary, ledger-rules spec [ES-9a].

Attributes

Inherited from:
EmulatorJavaApi (hidden)

Look up a previously applied transaction by hash, or None if it was never applied.

Look up a previously applied transaction by hash, or None if it was never applied.

Attributes

Inherited from:
EmulatorBase

The applied transaction with the given hash, or null if unknown.

The applied transaction with the given hash, or null if unknown.

Attributes

Inherited from:
EmulatorJavaApi (hidden)

The current UTxO set as a Java map.

The current UTxO set as a Java map.

Attributes

Inherited from:
EmulatorJavaApi (hidden)

The gov state: the proposals in the order they were submitted, with their votes, the enacted roots, the committee and the constitution, spec [ES-9]. One proposal is govState.proposal(id); one DRep state is certState.vstate.dreps(credential), D35.

The gov state: the proposals in the order they were submitted, with their votes, the enacted roots, the committee and the constitution, spec [ES-9]. One proposal is govState.proposal(id); one DRep state is certState.vstate.dreps(credential), D35.

Attributes

Inherited from:
EmulatorBase
def hasTx(txHash: TransactionHash): Boolean

Whether the tx is in appliedTxLog: in a block of the selected chain above the clearAppliedTxs cursor, or in the log the emulator was built with. A pending tx, in the Manual preset, reads false. txStatus reads the blocks only, so a tx of the imported log is NotFound there.

Whether the tx is in appliedTxLog: in a block of the selected chain above the clearAppliedTxs cursor, or in the log the emulator was built with. A pending tx, in the Manual preset, reads false. txStatus reads the blocks only, so a tx of the imported log is NotFound there.

Attributes

Inherited from:
EmulatorBase

Every failure of transaction under the ledger rules of this emulator, as the ledger collects them, in the order of the ledger's interpreter, ledger-rules spec [FL-1], [FL-8]. Empty when the rules accept it. A dry run on the state that submitSync validates against: the state does not change.

Every failure of transaction under the ledger rules of this emulator, as the ledger collects them, in the order of the ledger's interpreter, ledger-rules spec [FL-1], [FL-8]. Empty when the rules accept it. A dry run on the state that submitSync validates against: the state does not change.

submitSync reports one failure, which need not be the first of this list. TransactionException.ledgerNames names each failure with its cardano-ledger constructors.

It runs validators and mutators, not processTransaction: a subclass that overrides processTransaction to check other rules does not change this list.

Attributes

Inherited from:
EmulatorBase

The whole ledger state in the shape of the node's NewEpochState, read from one state, ledger-rules spec D122: the UTxO and cert state, the gov state, the account state, the stake snapshots, the reward update, the ratify result, the pparams and the pool distribution. Its fields equal the getters above; its treasury is treasury, spec [DM-13].

The whole ledger state in the shape of the node's NewEpochState, read from one state, ledger-rules spec D122: the UTxO and cert state, the gov state, the account state, the stake snapshots, the reward update, the ratify result, the pparams and the pool distribution. Its fields equal the getters above; its treasury is treasury, spec [DM-13].

Attributes

Inherited from:
EmulatorBase
override protected def mapF[A, B](fa: Future[A])(f: A => B): Future[B]

Map over the Future effect using this reader's captured ExecutionContext.

Map over the Future effect using this reader's captured ExecutionContext.

Attributes

Definition Classes
Inherited from:
BlockchainReader

The pending txs, oldest first.

The pending txs, oldest first.

Attributes

Inherited from:
EmulatorBase

The ratify result the last epoch boundary computed, which the next boundary enacts, ledger-rules spec [ES-9b], [EB-10a], D94: the enacted ids in order, the expired ids, and the enact state after the run. At genesis it enacts nothing, spec [DM-9c]. What a boundary enacted shows after it in govState, the pparams and the balances.

The ratify result the last epoch boundary computed, which the next boundary enacts, ledger-rules spec [ES-9b], [EB-10a], D94: the enacted ids in order, the expired ids, and the enact state after the run. At genesis it enacts nothing, spec [DM-9c]. What a boundary enacted shows after it in govState, the pparams and the balances.

RATIFY never accepts a HardForkInitiation to protocol version 12 or more, spec [EN-4a], D91: such an action delays nothing, and it expires with its deposit refunded.

Attributes

Inherited from:
EmulatorBase

The reward update the last epoch boundary computed from go, which the next boundary pays, ledger-rules spec [ES-9a], [RW-21]. None before the first boundary, spec [ES-8a].

The reward update the last epoch boundary computed from go, which the next boundary pays, ledger-rules spec [ES-9a], [RW-21]. None before the first boundary, spec [ES-8a].

Attributes

Inherited from:
EmulatorBase
override def pollForConfirmation(txHash: TransactionHash, maxAttempts: Int, delayMs: Long): Future[TransactionStatus]

Wait for the transaction to leave the mempool, without sleeping, spec [SF-2]: with AwaitTxPolicy.ProduceBlock, forge a block while it is Pending, at most maxAttempts blocks, spec [SF-3]; with AwaitTxPolicy.WaitOnly, report the status as it is, spec [SF-4]. delayMs is ignored: the emulator has virtual time.

Wait for the transaction to leave the mempool, without sleeping, spec [SF-2]: with AwaitTxPolicy.ProduceBlock, forge a block while it is Pending, at most maxAttempts blocks, spec [SF-3]; with AwaitTxPolicy.WaitOnly, report the status as it is, spec [SF-4]. delayMs is ignored: the emulator has virtual time.

Attributes

Definition Classes
Inherited from:
EmulatorBase
def produceBlock(on: ChainPoint, slot: SlotNo, txs: Seq[Transaction]): Either[ForgeError, ChainPoint]

Forge a block of txs at slot on on, a block anywhere in the block tree, or ChainPoint.origin for genesis, and return its point, spec section 8.2. It models a block from another pool: the txs come from the caller, not from the mempool, spec [FG-20].

Forge a block of txs at slot on on, a block anywhere in the block tree, or ChainPoint.origin for genesis, and return its point, spec section 8.2. It models a block from another pool: the txs come from the caller, not from the mempool, spec [FG-20].

The txs are applied in order to the ledger after on, spec [FG-15]. Then chain selection runs, spec [FG-19]: a branch longer than the selected chain becomes the selected chain, and the txs of the blocks it replaces follow the orphanTxs policy, spec section 11. On an error nothing changes, spec [FG-17].

Attributes

Inherited from:
EmulatorBase
def produceBlock(on: ChainPoint, txs: Seq[Transaction]): Either[ForgeError, ChainPoint]

Forge a block of txs on on, at slot on.slot + 1, spec [FG-11]. See the overload with a slot.

Forge a block of txs on on, at slot on.slot + 1, spec [FG-11]. See the overload with a slot.

Attributes

Inherited from:
EmulatorBase

Forge a block from the mempool, and return its point, spec section 8.1.

Forge a block from the mempool, and return its point, spec section 8.1.

In the Manual preset this is the only way a block appears: at slot max(current slot, tip slot + 1), with the longest prefix of the mempool that fits the block limits, after the current slot moves there and the mempool is revalidated, spec [FG-1], [FG-3], [FG-4]. An empty mempool forges an empty block, spec [FG-8].

Attributes

Inherited from:
EmulatorBase
inline def queryUtxos(inline f: Utxo => Boolean): UtxoQueryWithReaderTF[Future]

Query UTxOs using a lambda DSL.

Query UTxOs using a lambda DSL.

Translates the lambda to a UtxoQuery at compile time and returns a builder that can be further configured before execution. Effect-polymorphic — the resulting .execute() returns the reader's own F[Either[UtxoQueryError, Utxos]], so the same call shape works on Future-typed providers (Blockfrost, JS) and direct-style providers (ox Id).

Example:

// Simple query — execute immediately
reader.queryUtxos { u =>
 u.output.address == myAddress
}.execute()

// With pagination and minimum total
reader.queryUtxos { u =>
 u.output.address == myAddress && u.output.value.hasAsset(policyId, assetName)
}.minTotal(Coin.ada(100)).limit(10).execute()

Supported expressions:

  • u.output.address == addr — query by address
  • u.input.transactionId == txId — query by transaction
  • u.output.value.hasAsset(policyId, assetName) — query/filter by asset
  • u.output.value.coin >= amount — filter by minimum lovelace
  • u.output.hasDatumHash(hash) — filter by datum hash
  • && — AND combination
  • || — OR combination

Value parameters

f

Lambda expression from Utxo to Boolean

Attributes

Returns

A UtxoQueryWithReaderTF builder over this reader's effect type

Inherited from:
BlockchainReaderTF
def removeUtxo(input: TransactionInput): Unit

Removes a UTxO from the ledger directly, bypassing transaction validation. A no-op if no UTxO sits at that input.

Removes a UTxO from the ledger directly, bypassing transaction validation. A no-op if no UTxO sits at that input.

A datum the removed UTxO carried inline stays in the datum store: a node keeps answering for a datum it has seen after the output holding it is spent, and so does this.

Attributes

Inherited from:
EmulatorBase
def reserves: Coin

The reserves, ledger-rules spec [ES-9]. They start as EmulatorInitialState.reserves, the mainnet reserves by default, spec [ES-7].

The reserves, ledger-rules spec [ES-9]. They start as EmulatorInitialState.reserves, the mainnet reserves by default, spec [ES-7].

Attributes

Inherited from:
EmulatorBase
def rollback(n: Int): Either[RollbackError, ChainPoint]

Remove the last n blocks of the selected chain, and every block that descends from them, and return the tip after chain selection, spec section 11.3. The txs of the removed blocks follow the orphanTxs policy, and the current slot stays, spec [RB-6], [RB-7].

Remove the last n blocks of the selected chain, and every block that descends from them, and return the tip after chain selection, spec section 11.3. The txs of the removed blocks follow the orphanTxs policy, and the current slot stays, spec [RB-6], [RB-7].

Attributes

Inherited from:
EmulatorBase
def setSlot(slot: SlotNo): Unit

Move the current slot to slot, then revalidate the mempool, spec section 10. Each epoch boundary crossed costs one epoch transition, so a move across millions of epochs is slow.

Move the current slot to slot, then revalidate the mempool, spec section 10. Each epoch boundary crossed costs one epoch transition, so a move across millions of epochs is slow.

Attributes

Throws
IllegalArgumentException

in the Manual preset, for a slot below the slot of the tip block, spec [RV-8]

Inherited from:
EmulatorBase

An independent emulator starting from this one's state, taken as a single read — the copy and the original share no mutable cell and evolve separately from here on. The copy starts from the whole state, so it keeps the fees, the donations and the treasury, spec [SC-7c].

An independent emulator starting from this one's state, taken as a single read — the copy and the original share no mutable cell and evolve separately from here on. The copy starts from the whole state, so it keeps the fees, the donations and the treasury, spec [SC-7c].

Attributes

Inherited from:
EmulatorBase

The stake snapshots mark, set and go and the fee snapshot, as of the last epoch boundary, ledger-rules spec [ES-9a]. The genesis fills all three from the initial state, spec [ES-8a].

The stake snapshots mark, set and go and the fee snapshot, as of the last epoch boundary, ledger-rules spec [ES-9a]. The genesis fills all three from the initial state, spec [ES-8a].

Attributes

Inherited from:
EmulatorBase

Live stake per registered stake credential: the lovelace sitting at addresses delegating to it, plus its reward balance, and the pool it delegates to.

Live stake per registered stake credential: the lovelace sitting at addresses delegating to it, plus its reward balance, and the pool it delegates to.

This is the emulator's answer to "who controls how much stake", the query a governance or delegation test needs. It is the stake now, not a stake snapshot: snapshots holds the stake of the last epoch boundaries, which the rewards read. A row here may be for a credential that is not registered or delegates to no pool; a snapshot has no such row.

The coin is the ledger's instant stake, the one SNAP reads: pointer, enterprise and Byron addresses carry none.

Reads the state cell once, the way snapshot does. Two reads would let a submission land between them on the JVM, producing a row whose stake came from the post-transaction UTxO set and whose rewards came from the pre-transaction certificate state.

Attributes

Inherited from:
EmulatorBase
def submit(transaction: Transaction, debugScripts: Map[ScriptHash, DebugScript]): Future[Either[SubmitError, TransactionHash]]

Submit a transaction with debug scripts for diagnostic replay.

Submit a transaction with debug scripts for diagnostic replay.

When a release script fails with empty logs, the evaluator replays it using the debug script to produce diagnostic output.

Value parameters

debugScripts

map from release script hash to debug script for diagnostic replay

transaction

the transaction to submit

Attributes

Inherited from:
EmulatorBase
def submit(transaction: Transaction): Future[Either[SubmitError, TransactionHash]]

Submits a transaction to the network.

Submits a transaction to the network.

Attributes

Inherited from:
EmulatorBase
def submitAndPoll(transaction: Transaction, maxAttempts: Int = ..., delayMs: Long = ...): Future[Either[SubmitError, TransactionHash]]

Submit a transaction and poll until confirmed.

Submit a transaction and poll until confirmed.

Default implementation composes submit and pollForConfirmation.

Attributes

Inherited from:
BlockchainProvider
final def submitAsync(transaction: Transaction): CompletableFuture[SubmitResult]

CompletableFuture variant of trySubmit, for API-shape parity with asynchronous BlockchainProvider implementations.

CompletableFuture variant of trySubmit, for API-shape parity with asynchronous BlockchainProvider implementations.

Attributes

Inherited from:
EmulatorJavaApi (hidden)
def submitSync(transaction: Transaction, debugScripts: Map[ScriptHash, DebugScript]): Either[SubmitError, TransactionHash]

Synchronously submit a transaction with debug scripts for diagnostic replay.

Synchronously submit a transaction with debug scripts for diagnostic replay.

Attributes

Inherited from:
EmulatorBase
def submitSync(transaction: Transaction): Either[SubmitError, TransactionHash]

Attributes

Inherited from:
EmulatorBase
def tick(n: Long): Unit

Attributes

Inherited from:
EmulatorBase
def tip: ChainTip

The tip of the selected chain, or ChainTip.origin before the first block.

The tip of the selected chain, or ChainTip.origin before the first block.

Attributes

Inherited from:
EmulatorBase
def treasury: Coin

The treasury as of the last epoch boundary, the value a tx must state as its currentTreasuryValue. It lives in the env, spec [SC-6], so it starts as initialContext.env.treasury.

The treasury as of the last epoch boundary, the value a tx must state as its currentTreasuryValue. It lives in the env, spec [SC-6], so it starts as initialContext.env.treasury.

Attributes

Inherited from:
EmulatorBase
final def tryProduceBlock(on: ChainPoint, slot: Long, txs: List[Transaction]): EmulatorResult[ForgeError, ChainPoint]

produceBlock on a branch at slot with a Java list, spec section 8.2.

produceBlock on a branch at slot with a Java list, spec section 8.2.

Attributes

Inherited from:
EmulatorJavaApi (hidden)

produceBlock on a branch with a Java list: forge txs on on, at slot on.slot + 1, spec [FG-11].

produceBlock on a branch with a Java list: forge txs on on, at slot on.slot + 1, spec [FG-11].

Attributes

Inherited from:
EmulatorJavaApi (hidden)

rollback, with the result as an EmulatorResult, spec section 11.3.

rollback, with the result as an EmulatorResult, spec section 11.3.

Attributes

Inherited from:
EmulatorJavaApi (hidden)
final def trySubmit(transaction: Transaction, debugScripts: Map[ScriptHash, DebugScript]): SubmitResult

Like trySubmit, evaluating failing scripts against the given debug scripts for diagnostics.

Like trySubmit, evaluating failing scripts against the given debug scripts for diagnostics.

Attributes

Inherited from:
EmulatorJavaApi (hidden)
final def trySubmit(transaction: Transaction): SubmitResult

Submits a transaction and reports the outcome as a SubmitResult (never throws for a rejected transaction).

Submits a transaction and reports the outcome as a SubmitResult (never throws for a rejected transaction).

Attributes

Inherited from:
EmulatorJavaApi (hidden)

The status of the tx txHash, spec [TS-1]. It reads the mempool and the blocks, not the applied-tx log: a tx known only from the log the emulator was built with is NotFound.

The status of the tx txHash, spec [TS-1]. It reads the mempool and the blocks, not the applied-tx log: a tx known only from the log the emulator was built with is NotFound.

Attributes

Inherited from:
EmulatorBase
def utxos: Utxos

Attributes

Inherited from:
EmulatorBase

Deprecated and Inherited methods

def clearAppliedTxs(): Unit

Clear the applied-transaction bookkeeping (appliedTxLog and appliedTxIndex), leaving the ledger state (utxos, certState, datums) untouched.

Clear the applied-transaction bookkeeping (appliedTxLog and appliedTxIndex), leaving the ledger state (utxos, certState, datums) untouched.

The blocks stay: the log drops the imported log and then starts above the tip, spec [DE-4].

Attributes

Deprecated
[Since version 1.4.1] the selected chain is the applied-tx log; start a new Emulator for an empty log
Inherited from:
EmulatorBase

Concrete fields

val mutators: Iterable[Mutator]
val validators: Iterable[Validator]